Paket
From Joomla! Documentation
Anmerkung zu komponentenabhängigen Modulen
Manche Module (oder Plugins etc.) verwenden Models, Helpers u.ä. einer Komponente. In diesen Fällen wäre es wünschenswert, das Modul so zu packen, dass es deinstalliert wird, sobald die Komponente selber deinstalliert wird. Dieses dependency management wird in Joomla! zwar angestrebt, aber bisher nicht umgesetzt. Es wird empfohlen, den Standards zu folgen und ein Paket zu verwenden wie unten beschrieben.
Was ist ein Paket?
Ein Paket ist eine Erweiterung, mit der mehrere Erweiterungen auf einmal installiert werden. Dies wird z.B. verwendet, wenn man eine Komponente und ein Modul hat, die voneinander abhängig sind. Wenn diese in einem Paket kombiniert werden, kann der Benutzer die beiden Erweiterungen in einem Rutsch installieren und deinstallieren. Paket-Erweiterungen können ab Joomla
verwendet werden.
Wie erstellt man ein Paket?
Eine Paket-Erweiterung wird erstellt indem alle zip-Dateien der Erweiterungen zusammen mit einer XML-Manifest-Datei gepackt werden. Ein Paket besteht beispielsweise aus folgenden Bestandteilen:
- Komponente helloworld
- Modul helloworld
- Bibliothek helloworld
- System-Plugin helloworld
- Template helloworld
Das Paket sollte die folgende Baumstruktur in der zip-Datei haben:
-- pkg_helloworld.xml
-- packages <dir>
|-- com_helloworld.zip
|-- mod_helloworld.zip
|-- lib_helloworld.zip
|-- plg_sys_helloworld.zip
|-- tpl_helloworld.zip
-- pkg_script.php
Die Datei pkg_helloworld.xml könnte folgendermaßen aussehen:
<?xml version="1.0" encoding="UTF-8" ?>
<extension type="package" version="1.6" method="upgrade">
<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>
<scriptfile>pkg_script.php</scriptfile>
<files folder="packages">
<file type="component" id="com_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>
When you zip this and try to install it, you will see that every extension will be installed. Also the package will be visible in the extension list to uninstall all the extension of this package.
Remember to use the package uninstaller instead of individual subpackage uninstallers to avoid orphan extension entries in the extension manager.
Id= <file id="not_arbitrary">
The id element in <file ..> tag are NOT arbitrary!. The "id=" should be set to the value of the "element" column in the "#__extensions" table. If they are not set correctly, upon uninstalling of the package the children ( <file> ) will NOT be found and uninstalled.
Manifest filename and packagename
The naming of the manifest file and the ability to uninstall the package file itself are closely related. The manifest file must have a "pkg_" prefix, the remainder of the manifest name ( without .xml extension ) is to be used as <packagename>. Or, the other way around, a package you want to identify as "blurpblurp_J3" get that as its <packagename> and should be in a manifest file named "pkg_blurpblurp_J3.xml". Failure to do so will make it impossible to uninstall the package itself.
An optional <pkg_script.php> which contains a class pkg_<packagename>InstallerScript with public function postflight can be used (works in Joomla! 3.6).
Extension tag
As of Joomla! 3.4, you should include method="upgrade" in the <extension> tag if you wish for your package to succeed in updating itself on subsequent installations.
The version attribute of the <extension> tag should be set to the minimum supported version of Joomla for this package. For example, if your package only supports Joomla! 3.2 and above set this to 3.2.