Joomla 两个模块使用相同的 helper.php
我为 Joomla 构建了两个自定义模块(“预订”和“联系”),它们工作得很好,但是我有时必须升级它们。 是否可以让它们共享相同的“helper.php”,以便我可以将代码保存在一个地方?例如,这两个模块的 post 函数是相同的。我希望“联系”模块使用“预订”helper.php post 功能。 谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需将预订模块助手包含在联系人模块中并使用它即可。
例如,假设您的模块是 mod_reservation 和 mod_contact,在 mod_contact.php 中您包含预订帮助程序文件并按如下方式使用它:
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:
或者您制作一个自定义帮助模块,这是其他两个模块工作所必需的。我不确定,但我认为您可以在安装模块时检查其他模块。在该检查中,您检查辅助模块,如果不存在,则会给出错误。您还可以说某个模块至少需要帮助程序模块的 X.XX.XX 版本,如果版本太长也会在模块安装过程中给出错误。
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.