Page 1 of 1

How to use NewsArticleAdded Event and User Defined Tags?

Posted: Wed Aug 27, 2008 1:12 pm
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?

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

Posted: Mon Sep 15, 2008 2:45 am
by goodsamaritan
Bump.

Anyone have the answer to this?
I'm sure someone has done this.

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

Posted: Mon Sep 15, 2008 10:48 am
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?

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

Posted: Tue Sep 16, 2008 7:41 am
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

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

Posted: Fri Sep 26, 2008 3:37 am
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.

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

Posted: Fri Sep 26, 2008 6:29 am
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 ?