How to use NewsArticleAdded Event and User Defined Tags?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
goodsamaritan
Forum Members
Forum Members
Posts: 21
Joined: Sat Feb 02, 2008 10:21 am

How to use NewsArticleAdded Event and User Defined Tags?

Post by goodsamaritan »

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?
goodsamaritan
Forum Members
Forum Members
Posts: 21
Joined: Sat Feb 02, 2008 10:21 am

Re: How to use NewsArticleAdded Event and User Defined Tags?

Post by goodsamaritan »

Bump.

Anyone have the answer to this?
I'm sure someone has done this.
Russ
Power Poster
Power Poster
Posts: 813
Joined: Fri Nov 25, 2005 5:02 pm
Location: North West England

Re: How to use NewsArticleAdded Event and User Defined Tags?

Post by Russ »

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?
alby

Re: How to use NewsArticleAdded Event and User Defined Tags?

Post by alby »

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.
You have try (for example)?

Code: Select all

.................
$bodytext = 'Article text content: ' . $params['content'];
$subjecttext = 'Add article: ' . $params['title'];
.................
$cmsmailer->SetBody($bodytext);
$cmsmailer->SetSubject($subjecttext);
.................
Alby
goodsamaritan
Forum Members
Forum Members
Posts: 21
Joined: Sat Feb 02, 2008 10:21 am

Re: How to use NewsArticleAdded Event and User Defined Tags?

Post by goodsamaritan »

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.
goodsamaritan
Forum Members
Forum Members
Posts: 21
Joined: Sat Feb 02, 2008 10:21 am

Re: How to use NewsArticleAdded Event and User Defined Tags?

Post by goodsamaritan »

I'm fiddling with my User Defined Function:

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();
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 ?
Post Reply

Return to “Modules/Add-Ons”