Joomla 两个模块使用相同的 helper.php

发布于 2024-10-15 23:39:23 字数 170 浏览 13 评论 0原文

我为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅听莫相离 2024-10-22 23:39:23

您只需将预订模块助手包含在联系人模块中并使用它即可。
例如,假设您的模块是 mod_reservation 和 mod_contact,在 mod_contact.php 中您包含预订帮助程序文件并按如下方式使用它:

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

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();
东北女汉子 2024-10-22 23:39:23

或者您制作一个自定义帮助模块,这是其他两个模块工作所必需的。我不确定,但我认为您可以在安装模块时检查其他模块。在该检查中,您检查辅助模块,如果不存在,则会给出错误。您还可以说某个模块至少需要帮助程序模块的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文