Joomla : Apply content plugin only to content or k2

Question:

I developed a plugin extension for joomla article in that I controlled and modified some content but this control also refelect to k2 item page / other content.

How to apply my plugin only to joomla article / k2 item

Answer

To apply plugin content only to joomla article use following code

 
public function onContentAfterDisplay($context, &$article, &$params, $page = 0){
 if($context == 'com_content.article'){
 Your code here
 -----------------------------
 -----------------------------
 
 }
}

To apply plugin content only to k2 item use following code

 
public function onContentAfterDisplay($context, &$article, &$params, $page = 0){
 if($context == 'com_k2.item'){
 Your code here
 -----------------------------
 -----------------------------
 
 }
}

You can also apply above code in single plugin

 
public function onContentAfterDisplay($context, &$article, &$params, $page = 0){
 if($context == 'com_k2.item'){
 Your code here
 -----------------------------
 -----------------------------
 
 }
 if($context == 'com_content.article'){
 Your code here
 -----------------------------
 -----------------------------
 
 }
}

Related Posts:

Leave a Reply

* Name:
* E-mail: (Not Published)
   Website: (Site url withhttp://)
* Comment:
Type Code