简体   繁体   English

安装组件时在joomla 3.0中安装插件

[英]Plugin installation in joomla 3.0 when component install

I am trying to create new component with plugin in joomla 3.0 我正在尝试用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. 为此,我创建了插件xml。

and in main manifest.xml file i write this code. 在主manifest.xml文件中,我编写了这段代码。

<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. 我想从$ this-> manifest获取插件信息,但清单不返回任何类似插件的对象。

Please help, 请帮忙,

Thanks in advance. 提前致谢。

Mayur. 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. 然后,您使用这两个zipfile来创建第三个zipfile,以及一个名为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. 然后,Joomla将自动将两个扩展一起安装。

Hi I solved this problem grabbing the tmp path, of the plugin, and calling the installer class. 嗨,我解决了这个问题,它抓住了插件的tmp路径,并调用了安装程序类。 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 ... 如果路径存在,包是否有效等等,还可以执行一些其他检查...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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