Joomla two module using same helper.php

核能气质少年 提交于 2019-12-23 01:41:49

问题


I've built two custom modules for Joomla ("reservation" and "contact") which are working just fine, however time to time I have to upgrade them. Is it possible to make them to share the same "helper.php" so I could keep code in one place? For example the post function is the same for these two modules. I want the "contact" module to use the "reservation" helper.php post function. Thanks


回答1:


You can simply include the reservation module helper inside the contact module and use it. For example lets say that your modules are mod_reservation and mod_contact, in mod_contact.php you include the reservation helper file and use it like this:

require_once JPATH_SITE.DS."modules".DS."mod_reservation".DS."helper.php";
modReservationHelper::post();



回答2:


Or you make a custom helper module,, which is needed in order for the other 2 to work. I dont know for sure but I thought you can check for other modules when installing a module. In that check you check for the helper module and if not present you give a error. You could also say that a certain module needs atleast version X.XX.XX of the helper module and if the version is too long also give an error in during the install of the module.



来源:https://stackoverflow.com/questions/4903197/joomla-two-module-using-same-helper-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!