1

I want to bundle my template with a plugin, and I want the plugin is automatically published after template installation. I know this is possible with component or plugin installation, but is it possible to do that with template installation? How can I do that?

3

You need to create a package installer. A package can bundle template, modules, plugins, etc. in the same installable file.

See the Joomla docs for details of creating packages.

Currently, there is no native method for automatically enabling a plugin on installation, but you can do so with an additional script. Details of the scripted approach and a lengthy discussion of the pros and cons of adding a feature to auto-enable plugins can be found in this Joomla Developers thread on G+.

The scripted approach requires you to link to an additional script in your package manifest and then using that to enable your plugin:

Adding a scriptfile to the manifest:

<scriptfile>script.php</scriptfile>

Do this in your 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('pluginname'));
  $query->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
  $db->setQuery($query);
  $db->execute();
 }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.