0

这是我的插件:

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

// Import library dependencies
jimport('joomla.plugin.plugin');

class plgContentEya extends JPlugin
{

 function plgContentEya( &$subject, $config )
 {
    parent::__construct( $subject, $config );

 }
/**
 * Plugin method with the same name as the event will be called automatically.
 */
 function onAfterDisplayContent( &$article, &$params, $limitstart)
 {//Echo script there
echo "script works";
        // Plugin code goes here.
        // You can access parameters via $this->params.
    return "<script src='http://widget.eya.com/sprk.1.0.2.js' type='text/javascript'></script>";
 }
}




http://docs.joomla.org/Plugin/Events/Content

根据他们的文件

  Return Value
String. Returned value from this event will be displayed in a placeholder. Most templates display this placeholder after the article separator.

当我安装它时,该插件会显示并且不会引发错误。但该事件永远不会被触发。我在文档中没有看到

<install version="2.5" type="plugin" group="content">
   <name>plg_content_eya</name>
   <author>eya</author>
   <creationDate>February 2013</creationDate>
   <copyright>(C) 2013 Open Source Matters. All rights reserved.</copyright>
   <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
   <authorEmail>anattaligg@graeit.com</authorEmail>
   <authorUrl>www.eya.com</authorUrl>
   <version>2.5.0</version>
   <description>Adds eya plugin ot your site</description>
   <files>
     <filename plugin="eya">eya.php</filename>
   </files>

</install>
4

1 回答 1

2

根据version="2.5"您的 XML,您的插件没有被调用,因为您有错误的事件名称。

自Joomla的插件/事件/内容以来,事件名称已更改!1.5文件写好了。我已将其标记为 1.5 文档以说明这一点。

事件被重命名以更加一致(域/期间/事件,例如Content/After/Display),因此,您想要的事件现在被调用,您可以在文章“将 Joomla 1.5 扩展适配到 JoomlaonContentAfterSave ”中找到有关重命名事件的更多信息1.6 "

如果你想支持 Joomla!1.5 在您的插件中,您还必须添加一个兼容层来捕获 2.5 调用并将其重定向到您的方法。例如

// Catch 2.5
public function onContentAfterDisplay($article, $params, $limitstart)
{
    $result = $this->onAfterDisplayContent($article, $params, $limitstart);
    return $result;
}

注意 刚刚输入的未经测试的代码...

于 2013-02-10T22:41:50.110 回答