0
這是我的插件代碼:的Joomla事件不工作
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
// Import library dependencies
jimport('joomla.plugin.plugin');
class plgContentHideArticles extends JPlugin
{
/**
* Constructor
*/
function plgContentHideArticles(&$subject, $config)
{
parent::__construct($subject, $config);
}
/**
* Example prepare content method
*
* Method is called by the view
*
* @param object The article object. Note $article->text is also available
* @param object The article params
* @param int The 'page' number
*/
function onPrepareContent(&$article, &$params, $limitstart)
{
global $mainframe;
}
function onBeforeDisplayContent(&$article, &$params, $limitstart)
{
global $mainframe;
//add your plugin codes here
return 'test';
//return a string value. Returned value from this event will be displayed in a placeholder.
// Most templates display this placeholder after the article separator.
}
}
這是XML文件:
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="content">
<name>Content - HideArticles</name>
<author>Saleh Zamzam</author>
<creationDate>2014-11-23 15:33:47</creationDate>
<license>MIT License</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.example.com</authorUrl>
<version>1.0.0</version>
<description>Hide Custom Articles from Home page</description>
<files>
<filename plugin="hide_articles">hide_articles.php</filename>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.hide_articles.sys.ini</language>
<language tag="en-GB">language/en-GB/en-GB.hide_articles.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="Settings" label="Settings">
<field name="Ids" type="text" default="" label="Articles Ids" description="" size="100"/>
</fieldset>
</fields>
</config>
</extension>
的事件永遠不會被觸發。
請注意,插件沒有任何錯誤消息安裝成功。
我的,我想隱藏主頁定製文章,我會根據它在視圖上做的主要思想。
$view = JFactory::getApplication()->input->getString('view', '');
任何想法是什麼問題?
我修改了函數名'onContentPrepare',也沒有工作,很怪異的行爲。 – Saleh 2014-11-24 08:14:41
由joomla com_content擴展引發的oncontentprepare事件。如果您的主頁不包含任何文章,則此事件不會被觸發。 – Nick 2014-11-24 11:01:39
不,主頁至少有7篇文章 – Saleh 2014-11-24 12:54:39