The $context
parameter can be used to define if your plugin should run or not under certain circumstances. For example, you might want your plugin to run when displaying category blogs, but not when viewing the full article:
if ($context == "com_content.category") {
// Your code for category blog here
}
Some of the available contexts are:
com_content.category
com_content.article
com_content.featured
com_contact.category.title
com_tags.tag
(List contains only contexts I could confirm with a quick test, feel free to add more)
You can create a small plugin to see the different contexts:
<?php
// no direct access
defined('_JEXEC') or die;
class plgContentContext extends JPlugin
{
public function onContentPrepare($context, &$article, &$params)
{
echo '<h3 style="color:white;background:red">' . $context . '</h3>';
}
}
?>