[development] implementing "plugins"

Boris Mann boris at bryght.com
Fri May 5 19:29:57 UTC 2006


On 5-May-06, at 11:44 AM, Dan Robinson wrote:
>> 2) Do you want people to just drop .inc files into a plugins  
>> directory inside
>> your module?  For that, look at the flexinode module, which does  
>> exactly
>> that.  (There are lots of others, but that's the first one that  
>> comes to
>> mind.)  I've not looked at its guts in detail, but that's the  
>> direction you'd
>> want to go.
>>
> yeah - i started here - but I like the hook idea much better.
>> As for what gets included, If you're module is enabled then Drupal  
>> will
>> automatically include your mymodule.module file on every page  
>> load, but
>> that's it.  You can include/require whatever else you need/want.   
>> Note that
>> it is NOT included into the global namespace, so if you put stuff  
>> outside of
>> a function (which you shouldn't do), it won't be happening globally.
>>
> that's what I thought (that .module) are always included - thanks  
> for confirming.

Just to perhaps help make this distinction clear:
* implement a new hook_ call that other modules can implement
Pro: uses built-in "plugin" method of Drupal
Con: all modules always get included

* use custom .inc files for your module
Pro: potentially less load for large numbers of .inc files
Con: custom way of including functionality

The hook_ method likely outweighs any near term benefits that you  
MIGHT get from provisional inclusion, because EVERYONE benefits from  
making module inclusion/caching/etc. faster.

--
Boris Mann
Vancouver 778-896-2747 San Francisco 415-367-3595
SKYPE borismann
http://www.bryght.com



More information about the development mailing list