I’m trying to create a Joomla 1.7 content plugin that, ultimately, will send an email when a brand new article has been created on the backend. My plugin, while it installed correctly, doesn’t seem to be firing properly. I modified by plugin so that it should, on the creation of a new article, cancel the save event and display an error message instead. This isn’t happening, and articles are being saved just fine. Am I missing something obvious here? I even tried adding a die() and mail() command inside the onBeforeContentSave() method and it never got executed.
notifyy.xml
<?xml version="1.0" encoding="utf-8"?>
<extension version="1.7" type="plugin" group="content">
<name>Content - Notifyy</name>
<author>Andy Soell</author>
<creationDate>August 1, 2011</creationDate>
<copyright></copyright>
<authorEmail>my@email.com</authorEmail>
<authorUrl>http://andy.teamsoell.com</authorUrl>
<version>1.0</version>
<description>Notification for new articles</description>
<files>
<filename plugin="notifyy">notifyy.php</filename>
</files>
</extension>
notifyy.php
jimport( 'joomla.plugin.plugin' );
class plgContentNotifyy extends JPlugin {
function plgContentNotifyy( &$subject, $params )
{
parent::__construct( $subject, $params );
}
function onBeforeContentSave( &$article, $isNew )
{
global $mainframe;
$article->setError("i don't want to save this");
return false;
}
}
I feel silly, but Joomla’s site really needs to document their changes between versions a little better. It appears that the method names have changed from version 1.5 to 1.6, and their documentation still indicates the 1.5 names. The
onBeforeContentSave()method is now to be referenced asonContentBeforeSave().Further details found at: http://www.theartofjoomla.com/converting-old-extensions.html