简体   繁体   中英

Joomla plugin event not firing

I'm working on a plugin to work with a custom component I am developing for Joomla 3.3

However, with basic code firing in the event "onBeforeCompileHead", I am trying to update the canonical information that Joomla 3.3 produces, by taking all of the data from the array and resending it after modifying the data to add my own information.

However when adding custom code according to the Joomla programming guide (for starters) I do not see the code running nor does it add the head information needed for this test.

My code is as follows:

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.plugin.plugin'); 

class plgSystemCUSTOMPLUGIN extends JPlugin {

    function onBeforeCompileHead() {

        if ($this->params->get('site_url')) {

            $document = JFactory::getDocument();

            $headData = $document->getHeadData();

            $headData['metaTags']['standard']['revised'] = $this->params->get('site_url');

            $document->setHeadData($headData);

        } 

    }

}

I've taken the if statement out, it was not even hitting this point. I've even added a basic PHP mailer call to send a test email if this function was hit at all.

The plugin was installed as a "System" plugin. It is loading however the class into the framework, as I am able to cause syntax errors. I've also checked and the dispatcher in Joomla's core is definitely loading the event.

Does anyone have insight as to what is going on here?

Thanks!

I've figured this out. My language file was not using the proper name for the plugin, and this will only work if the class name is like:

class plgSystem[plugin_name] {

}

I now have this working as expected.

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM