Hello,
My objective is to send email to a mailing list whenever a new NEWS article on published on my website.
The clue I got from you helpful people is to use the EVENTS and use a User Defined Tag.
Yes, the EVENTS work and the User Defined Tag works, but I cannot understand how to use the fields of the NewsArticleAdded event manual in the User Defined Tag.
NewsArticleAdded
Sent when an article is added.
Parameters
\"news_id\" - Id of the news article
\"category_id\" - Id of the category for this article
\"title\" - Title of the article
\"content\" - Content of the article
\"summary\" - Summary of the article
\"status\" - Status of the article ("draft" or "publish")
\"start_time\" - Date the article should start being displayed
\"end_time\" - Date the article should stop being displayed
\"useexp\" - Whether the expiration date should be ignored or not
My user defined tag has
global $gCms;
$content =& $params['content'];
$bodytext = 'News from Eurasia Motorsport Team';
$cmsmailer =& $gCms->modules['CMSMailer']['object'];
$cmsmailer->AddAddress('my@emailaddress.com');
$cmsmailer->SetBody($bodytext);
$cmsmailer->IsHTML(false);
$cmsmailer->SetSubject('Subject Title');
$cmsmailer->Send();
My question is how do I use the fields / variables of NewsArticleAdded in the Subject and Body Text?
I've been fiddling with this for 2 days and I can't get it right.
Help pls?
How to use NewsArticleAdded Event and User Defined Tags?
-
- Forum Members
- Posts: 21
- Joined: Sat Feb 02, 2008 10:21 am
-
- Forum Members
- Posts: 21
- Joined: Sat Feb 02, 2008 10:21 am
Re: How to use NewsArticleAdded Event and User Defined Tags?
Bump.
Anyone have the answer to this?
I'm sure someone has done this.
Anyone have the answer to this?
I'm sure someone has done this.
Re: How to use NewsArticleAdded Event and User Defined Tags?
Well if you have the key for the news db (perhaps something like news article id) then just read the database and get the details yourself? There may well be a better way? but this will work! How you going to handle changes or updates and deletions?
Re: How to use NewsArticleAdded Event and User Defined Tags?
You have try (for example)?goodsamaritan wrote: My question is how do I use the fields / variables of NewsArticleAdded in the Subject and Body Text?
I've been fiddling with this for 2 days and I can't get it right.
Code: Select all
.................
$bodytext = 'Article text content: ' . $params['content'];
$subjecttext = 'Add article: ' . $params['title'];
.................
$cmsmailer->SetBody($bodytext);
$cmsmailer->SetSubject($subjecttext);
.................
-
- Forum Members
- Posts: 21
- Joined: Sat Feb 02, 2008 10:21 am
Re: How to use NewsArticleAdded Event and User Defined Tags?
Thanks for the tip... although my task is not finished.
I still do not know where to look so I can fend for myself.
Such as how did you know that $params['content'] gets the news article content and that $params['title'] is for the News Article Title?
How about for the News Article Summary? I just plugged in $params['summary'] and the user defined function hanged on me.
How about getting the News Article URL? What $params do I use?
Sorry for being a newbie.
I still do not know where to look so I can fend for myself.
Such as how did you know that $params['content'] gets the news article content and that $params['title'] is for the News Article Title?
How about for the News Article Summary? I just plugged in $params['summary'] and the user defined function hanged on me.
How about getting the News Article URL? What $params do I use?
Sorry for being a newbie.
-
- Forum Members
- Posts: 21
- Joined: Sat Feb 02, 2008 10:21 am
Re: How to use NewsArticleAdded Event and User Defined Tags?
I'm fiddling with my User Defined Function:
We are getting close to getting this "solved." Last 2 questions:
1. How to display the DATE of the article in human readable form?
2. And how to display the news article URL ?
Code: Select all
global $gCms;
$newsarticle =& $params['newsarticle'];
$subjecttext = 'News: ' . $params['title'];
$bodytext = 'Summary: ' . $params['summary'].
' Content: ' . $params['content'].
' Date: ' .
' Page URL: ';
$cmsmailer =& $gCms->modules['CMSMailer']['object'];
$cmsmailer->AddAddress('my@email');
$cmsmailer->IsHTML(false);
$cmsmailer->SetBody($bodytext);
$cmsmailer->SetSubject($subjecttext);
$cmsmailer->Send();
1. How to display the DATE of the article in human readable form?
2. And how to display the news article URL ?