如何使我的 drupal 模块具有条件依赖关系?
我正在尝试编写一个需要模块 a 或模块 b 的模块(不是两者都需要,尽管两者都可以)。它仅取决于 a 或 b。有没有办法将其放入 .info 文件或以编程方式强制执行此 OR 依赖项?
I'm trying to write a module that requires either module a or module b (not both, though having both is fine). It just dependent on a OR b. Is there a way to put this in the .info file or enforce this OR dependency programatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能在任何当前版本的 Drupal 中本地使用,有一个讨论讨论添加 <
.info
文件的 code>enhances[] 和enhancedby[]
属性(以及其他一些新属性),但尚未将其放入核心中就我而言可以告诉。如果您使用的是 Drupal 6,您可能会查看 Module Supports 模块,该模块是为了响应而创建的那个讨论。
如果您使用的是 Drupal 7,那么讨论可能会让您成功一半,如果没有的话,该页面上有一些补丁,至少会大致告诉您需要做什么来自己修补 Drupal 核心才能使其正常工作。
You can't natively in any current version of Drupal, there is a discussion here which talks about adding a
enhances[]
andenhancedby[]
property for.info
files (amongst a few other new properties), but it has not been put into core as far as I can tell.If you're using Drupal 6 you might have a look at the Module Supports module which was created in response to that discussion.
If you're using Drupal 7 the discussion might get you half way there, and if not there are a few patches on that page that will at least show you roughly what you need to do to patch Drupal core yourself to do get it working.
我看到其他模块实现这一点的唯一方法是在安装模块后报告问题,并且不将模块包含为依赖项。我认为这类似于 ckeditor 或 jquery_ui 等模块,它们需要放置非 Drupal 代码才能正常运行。
The only way I've seen other modules implement this is by reporting problems after a module is installed and not including the modules as dependent. I would assume this would be similar to modules like ckeditor or jquery_ui which require non-drupal code to be put in place to operate properly.