Closed svdaru closed 5 years ago
Hi,
you can use the build-in autoloader functionality https://yetiforce.com/en/knowledge-base/documentation/developer-documentation/item/loader-and-autoloader-of-files
The Loader allows to overwrite any system file. A folder named 'custom' needs to be added to the main CRM directory and a complete file path provided, e.g. custom/modules/Accounts/Accounts.php. The system will load the file Accounts.php instead of the original file. Currently, this solution works only for modules, but in the future the system will allow to change system files globally. A list of directories possible to overwrite:
modules/ModuleName/... >> custom/modules/ModuleName/... languages/... >> custom/languages/... layouts/vlayout/modules/... >> custom/layouts/vlayout/modules/...
In case of language files, the mechanism responsible for overwriting works differently. An empty language file has to be created and you should only add translations that need to be overwritten (no need to duplicate the entire language file).
@svdaru use link mechanism: https://github.com/YetiForceCompany/YetiForceCRM/blob/developer/modules/ModTracker/ModTracker.php#L171
@svdaru forgot to mention that this feature needs to be enabled in the perfomance.php config file
// Parameter that allows to disable file overwriting. After
// enabling it the system will additionally check whether the file exists in the custom directory.
// Ex. custom/modules/Assets/Assets.php
'LOAD_CUSTOM_FILES' => true,
'LOAD_CUSTOM_LANGUAGE' => true,
@svdaru use link mechanism: https://github.com/YetiForceCompany/YetiForceCRM/blob/developer/modules/ModTracker/ModTracker.php#L171
Thanks. As I understand, linkurl is interpreted at view controller. Is there a way to use static php function from any other module class to generate link?
@svdaru forgot to mention that this feature needs to be enabled in the perfomance.php config file
// Parameter that allows to disable file overwriting. After // enabling it the system will additionally check whether the file exists in the custom directory. // Ex. custom/modules/Assets/Assets.php 'LOAD_CUSTOM_FILES' => true, 'LOAD_CUSTOM_LANGUAGE' => true,
Thank you. That will help.
Is there any Instructions, Best practice guides etc for developing modules and functions?
Yetiforce (VTiger) architecture in some cases requires changing of embedded classes. For example, I need to add detail view link (DETAIL_VIEW_ADDITIONAL) to Account whit linkurl dynamically generated by other module function. In that case, I will change getDetailViewLinks function at Accounts_DetailView_Model class, which can be overwritten with upcoming Service Pack.
Another case is making custom function for getting related entities. For example, I create new module «Polices». One Account has many Polices, but relation logic is not standard and includes some additional conditions. Custom relation logic must include changing of Parent module (Account) functions.
What can you recommend to avoid merging Service Packs with locally changed files or to minimize (optimize) merging?