简体   繁体   中英

Plugin installation in joomla 3.0 when component install

I am trying to create new component with plugin in joomla 3.0

i successfully install component. my requirement is install plugin with component but some problem in installation.

For that i create plugin xml.

and in main manifest.xml file i write this code.

<plugins>
     <plugin plugin="switcher"  group="system">
         <files folder="plg_system_switcher">
        <file>switcher.php</file>
        <file>switcher.xml</file>
    </files>
     </plugin>
</plugins>

and i create script file afterinstall in that i write this code.

jimport('joomla.utilities.xmlelement');
jimport('joomla.utilities.simplexml');
$plugins = $this->manifest->plugins;

i want plugins info from $this->manifest but manifest not return any object like plugins.

Please help,

Thanks in advance.

Mayur.

I'm not sure I understand you correct. But if you want to install a component together with a plugin, you usually just install it as a package. For this you create a regular installation package for both the component and the plugin. So each is installable independent from the other wîth its own manifest and everything.

Those two zipfiles you then use to create a third zipfile together with an additional manifest file named plg_extensionname.xml. This manifest files looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
<extension type="package" version="3.0" method="upgrade">
    <name>Extensionname Package</name>
    <creationDate>2013-04-13</creationDate>
    <author>Author Name</author>
    <authorEmail>dummy@example.com</authorEmail>
    <authorUrl>http://www.example.com</authorUrl>
    <license>Creative Commons 3.0</license>
    <version>1.0</version>
    <packagename>extensionname</packagename>
    <description>Description for Extension</description>
    <files>
        <file type="component" id="com_extensionname" >com_extensionname.zip</file>
        <file type="plugin" id="plg_extensionname">plg_extensionname.zip</file>
    </files>
</extension>

Joomla will then automatically install both extensions together.

Hi I solved this problem grabbing the tmp path, of the plugin, and calling the installer class. All within the script file. Here is the code:

    public function install($adapter){
        $installer = JInstaller::getInstance();
        $path = $installer->getPath('source');
        $plugin_dir = $path.'/my_plugin_dir';

        $plugin_installer = new JInstaller();
        $plugin_installer->install($plugin_dir);
}

One could also perform some additional checks if the path exists, if the package is valid and so on ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM