How do I send email notification to the users when content will update
Hello,
I need to send email notification to a list of users in my csv file whenever any page is updated. I will upload the csv file under root.
Here is the format of CSV
-> columns headings : username,email,firstname,lastname -> columns data : someuser,[email blocked],some,user
It should start reading the email address + name of the user and send emails . Let say i have updated the page under
about_website -> about_courses -> courses (page).
So upon updating the page it should fetch the title of page + its url link and send email.
Can you please help me in this as this is the major part of any CMS site like many wordpress sites are doing this. Its a requirement from our institute to keep the users updated.
Thanks & Best Regards Uthman
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Ryan Griffith on 02 Nov, 2015 01:47 PM
Hi Uthman,
To confirm, are the users within the CSV file always the same regardless of the page, or does the list vary depending on the page?
Off-hand I think you could accomplish this in one of two ways:
Looking forward, we are discussing adding the ability for users to watch pages, which might help you in this case. Basically, anyone who wants to get an email about the page being updated would need to watch the page. This would in-turn allow them to opt out of being notified by un-watching. Also, with the addition of content owners, we are looking into adding more automated functionality to notify owners of assets.
Here is a related suggestion on our Idea Exchange, please feel free to vote it up if you would like this feature to be considered for a future release.
Please let me know if you have any questions.
Thanks!
2 Posted by usmanehsan0613 on 03 Nov, 2015 04:26 AM
Hello,
The list stays same for each page for now. the second option might be useful for me
" If you are willing to consider publishing the page an "update," you could use a custom publish trigger that calls an external script which reads your CSV file and emails accordingly. Again, if the recipients vary based on page you would need to tweak things a bit to determine who to send the email to, but it should be possible. "
How can i implement the above. where should i place external script , i am interesting to use javascript / jquery to send the request to some external php script.
Thanks,
3 Posted by Ryan Griffith on 03 Nov, 2015 01:20 PM
Hi Uthman,
My initial thought for the second option would be a custom Publish Trigger that would be executed every time an asset is published. In this publish trigger, you would check the asset type and send out an email.
Thinking through this a bit more, we suggested something similar to a client not long ago that might be of use.
To summarize:
#protect
and[system-view:internal]
pseudo tagsWith this setup, the JavaScript would run each time the page is viewed and is only output/ran when viewing the page within Cascade (hence the
[system-view:external]
tag). The cache/lookup would avoid sending notifications unnecessarily.I like this setup because it's much easier to add a region to the bottom of your Templates and drop a Velocity Format in for pages you want to send notifications for as opposed to maintaining the publish trigger. The downside is you are restricted to only page assets.
Please let me know if you have any questions.
Thanks!
4 Posted by usmanehsan0613 on 04 Nov, 2015 04:18 AM
Hi,
Can you please give me some example for such format. I am using xslt format .
Thanks,
5 Posted by usmanehsan0613 on 04 Nov, 2015 04:22 AM
e.g in wordpress you would do something like
add_action('save_post', 'send_email);
function send_email()
{ // here i can do whatever stuff i need to do . with a simple hook. // it will execute this function after post / page is saved. }
Would be great if you please give some quick and simple solution as we need to implement this quickly. Several days are passed and still no solution. Please help.
Thankyou.
Uthman
6 Posted by usmanehsan0613 on 04 Nov, 2015 08:55 AM
[system-view:external] or [system-view:internal]
If we put some javascript that will execute everytime that will create another issue. I only need some javascript code to run whenever the page is published.
Thanks,
7 Posted by Ryan Griffith on 04 Nov, 2015 03:07 PM
Hi Uthman,
You would use
[system-view:internal]
so the code is only executed and output when viewing the page within Cascade.As long as you use a caching system to check if the asset was updated after the cached timestamp, I don't foresee any major issues with the AJAX request executing each time the page is viewed. Are there other concerns you have?
The only other way to accomplish this would be a custom Publish Trigger, which also has it's downsides. For instance, a publish trigger will be invoked for every publishable asset type and, for pages, every individual output (since it's a separate publish job).
You could add a couple of checks to make sure the asset being published is a page and you are running the code for a single output, but you would still need a way to determine if the page was updated or not since a publish is not the same as an update. Similar to the JavaScript solution, you would need a means of recording the last time an email was sent to compare the asset's last modification time at the time of the publish.
With that said, IMO the JavaScript solution would be the simplest to implement and maintain since it won't require compiling a publish trigger
.jar
, dropping it into the installation directory, and restarting Cascade. Additionally, the.jar
needs to be re-added after upgrades.Assuming you are already loading jQuery on your pages, you could drop the following Velocity Format into a region that is at the bottom of your Template to issue a POST to an external script (ie
//domain.edu/script.php
) and passing some data about the page:In your external script, you would use the asset's ID as a key for the lookup table and compare it to the cached last modified timestamp to see if the timestamp provided is newer. If it is newer, send an email and update the cache with the new timestamp.
Please let me know if you have any questions.
Thanks!
8 Posted by usmanehsan0613 on 05 Nov, 2015 08:10 AM
Hello,
thanks for your detail reply.
For custom publisher it will be more complex to implement as server is mantained by other department.
For second option of using javascript / jquery ,I will not send email notification for each page rather i will fill a form within cascade having following fields.
and after filling this form i will submit and than jquery / javascript will post this information to some external script ie. domain.com/script.php , this script will do its job to send email notifications to all users.
I think above is easy to implement within cascades. Actually i want to keep control within cascade.
** So what i need from you is to know how can I fetch the form information within cascades and pass this information as json object. **
Hope above is clear and have a very easy solution.
Thanks & Best Regards,
Uthman
9 Posted by Ryan Griffith on 06 Nov, 2015 08:29 PM
Hi Uthman,
What you can do is give the form an ID attribute (e.g.
id="myform"
) and then you can use jQuery'sserialize()
method to serialize the form data to be sent to your script.If you are going this route, what you can do is output the form within your Velocity Format so you can essentially pre-fill the form. If you went this route, you could use hidden form fields with a submit button or link to submits the form, so you don't affect your page's markup too much.
You would have something like the following in your Format for example:
Please let me know if you have any questions.
Thanks!
10 Posted by usmanehsan0613 on 08 Nov, 2015 08:33 AM
Hi,
In my format i tried following
it throws error : Invalid XSLT: form is not allowed in this position in the stylesheet!
11 Posted by usmanehsan0613 on 08 Nov, 2015 08:34 AM
12 Posted by usmanehsan0613 on 08 Nov, 2015 08:34 AM
I tried to put the form in xslt but it throws error.
13 Posted by Ryan Griffith on 09 Nov, 2015 02:13 PM
Hi Uthman,
The code I provided is for a Velocity Format and not XSLT, this would explain the issue you are seeing.
Simply copy the code I provided and the
<form>
markup you were using into a Velocity Format and apply it to your page region and that should do the trick.Please let me know if you have any questions.
Thanks!
14 Posted by usmanehsan0613 on 10 Nov, 2015 05:15 AM
Hi Ryan,
Can we say that
<form>
is not supported by XSLT in cascades as in other examples for XSLT it does supports form tag.I do prefer to use XSLT because in my whole site i am using XSLT format.
Thanks,
Uthman
15 Posted by Ryan Griffith on 11 Nov, 2015 08:18 PM
Hi Uthman,
You can certainly use XSLT to accomplish this, I was just stating that you were combining Velocity code (i.e.
$currentPage
) with XSLT, which will not work. Also, your XSLT was not a valid Format.If you choose to use XSLT, you will need to apply a calling page Index Block along with the Format that also includes the asset's system metadata so you have access to the information you need.
When you have a moment, give the following a try for starters and let me know how it goes:
Please let me know if you have any questions.
Thanks!
Ryan Griffith closed this discussion on 25 Nov, 2015 01:39 PM.