2

Can you tell me how I can create a patch with some changes (for database manipulations) for my customer, so that he can install this patch via extension manager, and the installer of this kind of extensions does the manipulations?

I know we can create components, plugins and modules. But can we create patches?

  • A patch for what exactly? – Lodder Oct 31 '15 at 22:21
  • Database manipulations – El cero Oct 31 '15 at 22:21
  • Can you not simply make your changes to the database in PhpMyAdmin? – Lodder Oct 31 '15 at 23:28
  • It is intended for my client, who does not know what PhpMyAdmin is. He knows only how to install extensions in the backend. – El cero Nov 1 '15 at 1:30
3

You can try using an installation script, described quite well in the Joomla Documentation.

It consists in using a php script file containing a class using five methods:

  • preflight which is executed before install and update
  • install
  • update
  • uninstall
  • postflight which is executed after install and update

Create an empty module or plugin, and call the script in your .xml file:

<scriptfile>script.php</scriptfile>

Then create a file called script.php and include your patch code wherever you need it. This is the example script.php file from the documentation:

<?php
// No direct access to this file
defined('_JEXEC') or die;

/**
 * Script file of HelloWorld module
 */
class mod_helloWorldInstallerScript
{
    /**
     * Method to install the extension
     * $parent is the class calling this method
     *
     * @return void
     */
    function install($parent) 
    {
        echo '<p>The module has been installed</p>';
    }

    /**
     * Method to uninstall the extension
     * $parent is the class calling this method
     *
     * @return void
     */
    function uninstall($parent) 
    {
        echo '<p>The module has been uninstalled</p>';
    }

    /**
     * Method to update the extension
     * $parent is the class calling this method
     *
     * @return void
     */
    function update($parent) 
    {
        echo '<p>The module has been updated to version' . $parent->get('manifest')->version) . '</p>';
    }

    /**
     * Method to run before an install/update/uninstall method
     * $parent is the class calling this method
     * $type is the type of change (install, update or discover_install)
     *
     * @return void
     */
    function preflight($type, $parent) 
    {
        echo '<p>Anything here happens before the installation/update/uninstallation of the module</p>';
    }

    /**
     * Method to run after an install/update/uninstall method
     * $parent is the class calling this method
     * $type is the type of change (install, update or discover_install)
     *
     * @return void
     */
    function postflight($type, $parent) 
    {
        echo '<p>Anything here happens after the installation/update/uninstallation of the module</p>';
    }
}

Remember to rename the class to match your extension name (e.g. class mod_myPatchInstallerScript). The script file will be executed when your client installs the extension.

2

Will give this a shot.

With Joomla, there is no possible way to install "patches". The only files that can be installed though Joomla's extension manager are extensions, such as components, module, plugins etc.

So, what you could do is, create a blank module and install it.

Then, in the XML file for your module, add the following:

<update> 
    <schemas>
        <schemapath type="mysql">sql/mysql/updates</schemapath> 
    </schemas> 
</update>

Then, inside your module, you will need to create the directory tree:

sql/mysql/updates

Inside the updates directory, you'll need to create an SQL file each time you want install an update. Make sure the name of the SQL file is the same as the update version.

For example:

/updates
   1.0.0.sql
   1.0.1.sql
   1.0.2.sql

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.