Joomla: Apply plugin only to front-end / back-end

Question

How to apply a plugin only to front-end / back-end for a site

Answer

To apply plugin code only to front-end


function onBeforeRender() {
	
    //apply only to frontend only	
    $app = JFactory::getApplication();
    if($app->isSite())
    {
    Your code
    -----------------------
    -----------------------
    -----------------------
    }
    
}

To apply plugin code only to back-end


function onBeforeRender() {
	
    //apply only to backend only	
    $app = JFactory::getApplication();
    if(!$app->isSite())
    {
    Your code
    -----------------------
    -----------------------
    -----------------------
    }
    
}

To apply plugin code  front-end and back-end


function onBeforeRender() {
	
    //apply only to frontend only	
    $app = JFactory::getApplication();
    if($app->isSite())
    {
    Your code
    -----------------------
    -----------------------
    -----------------------
    }
    
    //apply only to backend only	
    $app = JFactory::getApplication();
    if(!$app->isSite())
    {
    Your code
    -----------------------
    -----------------------
    -----------------------
    }
    
}

Related Posts:

Leave a Reply

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