simon
simon

Reputation: 1191

Joomla: onContentAfterSave not triggered

I'm developing a Joomla plugin. Unfortunately, the necessary event is not fired. This means that the following code never gets executed:

public function onContentAfterSave($context, &$article, $isNew)
{
 ....
}

I have developed the plugin as usual. All other used events work fine. Can this be an internal Joomla \ PHP bug or am I missing something?

Apache/2.2.4 (Win32) mod_ssl/2.2.4 OpenSSL/0.9.8k PHP/5.3.3

Joomla! 2.5.4 Stable [ Ember ] 2-April-2012 14:00 GMT

Upvotes: 2

Views: 1396

Answers (2)

user1416258
user1416258

Reputation:

There's probably something not matching between the plugin name in your .xml file and the plugin name in your .php file.

[PluginName].php

<?php

defined('_JEXEC') or die;

jimport('joomla.event.plugin');  // I've also seen joomla.plugin.plugin.
                                 // Perhaps and older version
class plg[PluginGroup][PluginName]
{
    public function onContentAfterSave( $context, &$article, $isNew  )
    {
      // $db = JFactory::GetDBO();
      // etc...
    }
}
?>

[PluginName].xml

<?xml version="1.0" encoding="UTF-8"?>
<extension type="plugin" version="2.5.0" group="[PluginGroup]">
<name>[PluginName]</name>
<version>0.0.1</version>
<author></author>
<creationDate></creationDate>
<copyright></copyright>
<license></license>
<authorEmail></authorEmail>
<authorUrl></authorUrl>
<description></description>
<files>
  <filename plugin="[PluginName]">[PluginName].php</filename>
  <filename>[PluginName].xml</filename>
  <filename>index.html</filename>       
</files>
</extension>

Otherwise, please post more information:

  1. What else in your [pluginname].php and [pluginname].xml files.
  2. Have you installed the plugin correctly?
  3. Have you published the plugin after installation?

Upvotes: 4

Bobby Jack
Bobby Jack

Reputation: 16048

Have you definitely installed and enabled the plugin? It's easy to forget the latter, in particular.

Upvotes: 0

Related Questions