In PHP, if an existing class or API you like but you want to bring your personal touch you include it and overloading to avoid touching it.
Exactly the same principle applies with Jelix modules. We then speak of “overload”.
A module is not a simple class (but composed of controllers, daos, forms, templates, zones, classes, translation files) not everything can be overloaded.
What can be overload ?
Advantages of the “Overload” :
So take the module as a concrete example Jelix, jCommunity, and see what can be learned.
jCommunity is the management module of users for all kind of website. It includes a complet workflow of management :
Question
Ok that's cool but I want to adapt the rendering templates jCommunity the themes of my site. how?
Answer
By default the name of the theme is default.
So to override a template will be placed just the modified version of it in the folder var/themes/default/jCommunity
So when Jelix call the template of the module, it will first see if a version exists in the theme folder and use it.
Compare : the template of the view page of the membre :
Question
The table jCommunity does not contain enough of informations to manage my members, how to extend this one ?
Answer
Let's copy the Dao jcommunity/dao/user.dao.xml in the folder var/overload/jcommunity/daos
Let's change the content of what we need :
like previously Jelix will go to see first if one existing DAO is in that folder.
All of this by respecting a least the name of the existing method in the original DAO.
Compare : Dao account.dao.xml :
3) Overload of forms :
Question : The form managing the data of the users is too light for you ?
Answer :
Ok, let's make a copy of the forms jcommunity/forms/account.form.xml in the folder var/overload/jcommunity/forms Then we add the fields you need to see displayed (corresponding to our modified DAO).
Like previously Jelix will go to see first if one existing forms is in that folder.
Compare : the Forms account.forms.xml :
Ok everything is running well
We could overload as we wish.
Remains a last detail, after the overload of the presentation layer,
We need to extend the functionnal layer.
And this is made possible by the events Jelix
for example, when a member is subscribing, I wish to check if this one is not banned from the site.
For that, jCommunity manage an event jcommunity_registration_prepare_save, send just before the email member. By responding to this event (wih the listener) we are able to proceed to the checking without returning to the jCommunity the respond, positive or not. (little reminder on Events Jelix in a previous article )
So, when the call of jCommunity, and with the differents orverload, this are your own ressource that are used, while fully exploiting the core/workflow jCommunity.