Editing the core Jomres code

The plugin (AKA minicomponent) system is designed to allow users to create new scripts, and duplicates of existing scripts (e.g. j05000bookingobject.class.php) and put them in another folder to be run in place of the core minicomponents (these are the files in /jomres/core-minicomponents, where else?)

 

I could waffle on for ages about minicomponents and how they've evolved but it's always better to learn from a practical example.


Let's say for example want to modify the calcTax method in the booking engine (dobooking.class.php). What you should do is copy the j05000bookingobject.class.php file from the /jomres/core-minicomponents/ directory into the remote_plugins folder and a directory of it's own, for example called 'custom_code', giving you a directory structure public_html/jomres/remote_plugins/custom_code.

In the j05000bookingobject.class.php you can see the following.


class booking extends jomres_booking
    {
    }


We can edit the public_html/jomres/remote_plugins/custom_code/j05000bookingobject.class.php and override the standard Jomres engine's calcTax() method like so:


class booking extends jomres_booking
    {
    function calcTax()
        {
        <SNIP> Add your own code
        }
    }


Finally you want to tell Jomres to use this plugin instead of the default j05000bookingobject.class.php. Because you've put this file into the remote_plugins/custom_code folder (it can be named anything, 'custom_code' isn't mandatory) Jomres will find it when it rebuilds the registry, so rebuild the registry by running the Rebuild Registry feature in the administrator area of Jomres, or just delete jomres/temp/registry.php.

Editing other minicomponents is even easier. Let's say you want to modify the search minicomponent to output some new code. Again, copy the minicomponent (in this case j00030search.class.php) into the custom_code folder and edit it to do whatever you want. Rebuild the registry and you're done.

The remote_plugins folder isn't touched by Jomres during an upgrade so the customised code will not be overwritten however be aware that your code may not be making full use of any new functionality in the Jomres core.