Reputation: 2719
This my plugin code:
<?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.
}
}
And this is for xml file:
<?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>
The event never gets triggered.
Kindly note that plugin installed successfully without any error messages.
My main idea that I want to hide custom articles from home page and I'm going to do it depending on the view.
$view = JFactory::getApplication()->input->getString('view', '');
Any idea what is the problem?
Upvotes: 0
Views: 377
Reputation: 2512
Joomla 3.x does not trigger onPrepareContent event.
This event is triggered in older version of Joomla.
Use onContentPrepare event instead of onPrepareContent
Same goes with onBeforeDisplayContent event.
Refer to this link for all the content related events.
Upvotes: 1