2011-12-17 53 views
2

我已經爲Joomla 1.5創建了自定義組件和路由插件,爲我的組件提供了搜索引擎優化URL,並且還提供了與菜單無關的文章和類別。現在我必須單獨安裝我的組件和路由插件。有沒有辦法可以將兩者都安裝在一個包中?如何在一個包中安裝組件和路由插件?

預先感謝您! Vojtech

回答

4

當任何擴展安裝Joomla觸發事件'com_yourcomponent_install()'到你的安裝文件,你已經在xml文件中提到。

編寫一個函數com_yourcomponent_install中獲得的插件文件夾的路徑,並安裝它

$installer = new JInstaller(); 
// Install the packages 
$installer->install($pluginPath); 

例如

    在你的XML文件
  1. install.mycomponent.php
  2. 和安裝。 mycomponent.php應該有一個函數com_mycomponent_install()
  3. 這個函數將包含代碼爲

    $ installer = new JInstaller(); //安裝軟件包 $ installer-> install($ pluginPath);

+0

感謝。這就是我想要的兩天。 – Robot 2012-09-05 07:14:03

5

有一個更簡單的方法。

什麼是包裝?

軟件包是用於一次安裝多個擴展的擴展。

如何創建一個包?

通過將擴展的所有zip文件與xml清單文件一起壓縮,創建了一個包擴展。例如,如果你有一個由組成的包:

  • 組件的HelloWorld
  • 模塊的HelloWorld
  • 庫的HelloWorld
  • 系統插件的HelloWorld
  • 模板的HelloWorld

包應該有在您的zip文件中的以下樹:

-- pkg_helloworld.xml 
-- packages <dir> 
    |-- com_helloworld.zip 
    |-- mod_helloworld.zip 
    |-- lib_helloworld.zip 
    |-- plg_sys_helloworld.zip 
    |-- tpl_helloworld.zip 

的pkg_helloworld.xml可能具有以下內容:

<?xml version="1.0" encoding="UTF-8" ?> 
<extension type="package" version="1.6"> 
<name>Hello World Package</name> 
<author>Hello World Package Team</author> 
<creationDate>May 2012</creationDate> 
<packagename>helloworld</packagename> 
<version>1.0.0</version> 
<url>http://www.yoururl.com/</url> 
<packager>Hello World Package Team</packager> 
<packagerurl>http://www.yoururl.com/</packagerurl> 
<description>Example package to combine multiple extensions</description> 
<update>http://www.updateurl.com/update</update> 
<files folder="packages"> 
    <file type="component" id="helloworld" >com_helloworld.zip</file> 
    <file type="module" id="helloworld" client="site">mod_helloworld.zip</file> 
    <file type="library" id="helloworld">lib_helloworld.zip</file> 
    <file type="plugin" id="helloworld" group="system">plg_sys_helloworld.zip</file> 
    <file type="template" id="helloworld" client="site">tpl_helloworld.zip</file> 
</files> 
</extension> 
+3

軟件包自1.6開始提供,而問題被標記爲Joomla 1.5,所以未來的讀者應該注意,如果他們使用Joomla 1.5,他們可能無法一次安裝多個組件,插件,模塊等。 。 – 2013-04-05 15:05:10