php - How to auto enable the plugin during installation in Joomla? -


does way in joomla auto enable plugin during installation? have followed post topics not straight forward solution.

i have used below code during installation auto enabling plugin :

update `#__extensions` set `enabled` = 1 `element` = 'plugin_name'; 

but want know better solution.

/thanks

that's way way i'm aware of; detailed below others might stumble on trying figure out how it.

add scripfile manifest (xml), below </description> tag:

<scriptfile>my_script.php</scriptfile> 

my_script.php:

class plgsystempluginnameinstallerscript {  public function install($parent)  {   // enable plugin   $db  = jfactory::getdbo();   $query = $db->getquery(true);   $query->update('#__extensions');   $query->set($db->quotename('enabled') . ' = 1');   $query->where($db->quotename('element') . ' = ' . $db->quote('plugin_name_goes_here'));   $query->where($db->quotename('type') . ' = ' . $db->quote('plugin'));   $db->setquery($query);   $db->execute();  } } 

tip: if it's content plugin, replace plgsystempluginnameinstallerscript plgcontentpluginnameinstallerscript.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -