in Joomla, Tips and Tricks

My trouble story about ‘onContentPrepare’ hook for joomla

1. I was developing a content plugin for joomla, currently I was working with joomla1.6 or earlier.
2. My target was skip some specific or used defined category for the plugin execution as this is very useful feature.
3. It works in article details page but doesn’t work in other view of com_content component. Why
4. Here is the function that get’s hooked in content plugin for onContentPrepare

[code language=”php”]
* Example prepare content method
* Method is called by the view
* @param string The context of the content being passed to the plugin.
* @param object The content object. Note $article->text is also available
* @param object The content params
* @param int The ‘page’ number
* @since 1.6
public function onContentPrepare($context, &$article, &$params, $limitstart)
$app = JFactory::getApplication();


So the param $article will hold the text and other parameters that you can play with. What’s my trouble here , let me clear.

This is how the content plugins are added in article detailt view

[code language=”php”]
$results = $dispatcher->trigger(‘onContentPrepare’, array (‘com_content.article’, &$item, &$this->params, $offset));

and this is how same thing is done in category view 🙁

[code language=”php”]
$item->introtext = JHtml::_(‘content.prepare’, $item->introtext);

Did u get what’s the hell wrong. because in category view you will get only $article->text and nothing but for article view you will get all values of article table

just check var_dump($article)