简体   繁体   English

Joomla插件事件未触发

[英]Joomla plugin event not firing

I'm working on a plugin to work with a custom component I am developing for Joomla 3.3 我正在使用一个插件,该插件可以与我为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. 但是,使用事件“ onBeforeCompileHead”中的基本代码触发时,我试图通过从数组中获取所有数据并在修改数据后重新发送以添加我自己的信息来更新Joomla 3.3生成的规范信息。

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. 但是,根据Joomla编程指南(针对初学者)添加自定义代码时,我看不到代码正在运行,也没有添加此测试所需的头信息。

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. 我已经删除了if语句,甚至没有达到这一点。 I've even added a basic PHP mailer call to send a test email if this function was hit at all. 我什至添加了一个基本的PHP邮件程序调用,以发送测试电子邮件(如果该功能根本没有实现的话)。

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. 我也检查过,Joomla核心的调度程序肯定是在加载事件。

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! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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