开发者

Drupal API: how to load a module dependency from another module

I am attempting to develop a Drupal module that defines the class MyFeedsSyndicationParser. This class extends the class FeedsSyndicationParser from the Feeds module. In my module's .info file the dependency on the Feeds module is identified.

When I enable the module the php_error.log contains: PHP F开发者_开发问答atal error: Class 'FeedsSyndicationParser' not found in C:\wamp\apps\myapp\sites\all\modules\custom\myfeeds\MyFeedsSyndicationParser.inc on line 9

It seems that the FeedsSyndicationParser class has not yet been defined. Does Drupal have an API call that can be used to ensure that another module has been loaded? (In this case, the FeedsSyndicationParser.inc file.)


use this to include: http://api.drupal.org/api/function/module_load_include/6


There are two (better/proper) ways to do this.

  1. list it as a dependency in your .info file, so that it wont enable without it.
  2. use module_exists() to check if the module is installed & enabled (for say a views date filter that can optionally use the Date_API if it is present and enabled)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜