07/06/08
Joomla New Item Email Notification
This example is for Joomla 1.0.15
If you have worked with Joomla for any length of time you will have noticed that the workflow system has some room for improvement. Following is one way to work around this shortcoming.
When a new item is submitted from the public frontend a Private Message is sent to the Super Administrator. Wouldn’t it be great if we could customize this message and have a copy sent to an email of our choosing? Here is how you do it:
First, edit _ON_NEW_CONTENT in your language file. This is the content of your message. The English language file is located at /language/english.php.
DEFINE(‘_ON_NEW_CONTENT’,
"Hello,nA new content item has been submitted by [ %s ] titled [ %s ] for the section [ %s ] and category [ %s ].nPlease go to $mosConfig_live_site/administrator/ to view and approve this article.nPlease do not respond to this message as it is automatically generated and is for information purposes only." );
Second, add the following to the /component/com_content/content.php right around line 2400 right after:
foreach ($users as $user_id) {
$msg = new mosMessage( $database );
$msg->send( $my->id, $user_id, "New Item", sprintf( _ON_NEW_CONTENT, $my->username, $row->title, $section, $category ) );
}
Add:
mosMail
( "noreply@yourdomain.com",
"Admin",
"noreply@yourdomain.com",
"New Item",
sprintf( _ON_NEW_CONTENT,
$my->
username,
$row->
title,
$section,
$category ) );
Now an email containing the new content information will be sent in addition to the PM. You can set rules where you receive this email to check the section and/or category. Then simply forward the email to the publishers for those content groups. Hopefully the next version of Joomla will have better workflow capabilities built in.
Warning: This is a hack!
I personally hate hacks, but when the client asks for a feature that can’t easily be built into an extension sometimes it is the most efficient option. If you use this just be warned that you will have to re-apply this hack if you ever upgrade.
Disclaimer: This has worked for me, but please use at your own risk!
Thanks. Do you know if this could work in 1.5?
I haven’t tried setting this up in 1.5 as of yet, but I don’t see any reason why you couldn’t do something similar. I wouldn’t be surprised if someone has already found a way to do this without a hack in 1.5.
If I come across something I’ll post it here.
Great article. Love to hear if Justin was able to incorporate it into J1.5 or if you came across anything. I’m looking for this functionality for J1.5.8 now.
Cheers and keep up the great work!
Hy all!
No, with the version J1.5.X it doesn’t work. But you change it too.
You must change the com_messages.ini in your language folder.
——————
PLEASE LOGIN TO READ YOUR MESSAGE=the website url (%s) public. %s
——————
Important is the “%s” at the end.
Then you must change the file \administrator\components\com_messages\tables\messages.php
————————
$subject = sprintf (JText::_(‘A new private message has arrived’), $sitename);
$msg = sprintf (JText::_(‘Please login to read your message’), $siteURL, $message);
————————-
the change of this is the variable $message.
good luck!
cheers
It sounds like you’re creating problems yourself by trying to solve this issue instead of looking at why their is a problem in the first place
Not sure what you mean?
I’m working through the differences with 1.5 right now and so far these are the difference I’ve found to make this hack work :
The English (BG) language file is now /language/en-GB/en-GB.com_content.ini
Change the entry here to what you wish.
Then in /components/com_content/controller.php ~~ line 218 change the foreach loop here to say :
foreach ($users as $user_id)
{
JUtility::sendAdminMail($adminRow->name, $adminRow->email, ”, JText::_(‘New Item’), $post['title'], $user->get(‘username’), JURI::base());
$msg = new TableMessage($db);
$msg->send($user->get(‘id’), $user_id, JText::_(‘New Item’), JText::sprintf(‘ON_NEW_CONTENT’, $user->get(‘username’), $post['title'], $section, $category));
}
Cool. Thanks Owen.