Question

I have created a package in Joomla 3 that includes a module and a plugin. It installs both the module and plugin correctly but the plugin is disabled by default. Is there a way to make the plugin enabled by default- perhaps in the xml manifest of the package? I am unable to figure this out.

Was it helpful?

Solution

As @lodder already mentioned you can write your install script like

public function install ($parent)
{
    $query = "update `#__extensions` set enabled=1 where type = 'plugin' and element = 'your-extension'";
    $db = JFactory::getDBO();
    $db->setQuery($query);
    $db->query();

    // Probably you want to enable the module on all pages too
    $query = "insert into `#__modules_menu` (menuid, moduleid) select 0 as menuid, id as moduleid from `#__modules` where module like 'mod_my-awesome-menu%'";
    $db->setQuery($query);
    $db->query();
}

You can find my working example here https://github.com/Digital-Peak/DPAttachments/blob/master/com_dpattachments/script.php#L15

OTHER TIPS

I think the best way would be to run a sql statement after installation that get the plugin by ID and change its status from 0 to 1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top