[support] inter module communication, hooks and dependencies

Ivan Sergio Borgonovo mail at webthatworks.it
Fri Jan 2 14:17:32 UTC 2009


Hi,

The actual problem is providing an API to let modules add META in a
more structured way so that eg. the same META is not sent 2 times or
module can decide to concatenate further meta or define a
"owerwriteability" level.

I gave a look to nodewords aka Meta tags but I have stuff that
aren't nodes (they aren't views or taxonomies either) that don't fit
with the node paradigm too well.

nodewords provide a hook to 'prepare' META but it is on a module
base.
Nodewords needs to be aware of all the content types (or just pages,
menu_hook etc...) it can support (*unless I'm missing something...*)
but actually what know better which are the most suitable meta for a
"content" should be the content producer (be it a "node" or just a
MENU_CALLBACK).
Other modules like nodewords_bypath and _nodetype do some extrawork
to know what actually called the hook.
But I'd find myself more comfortable with a different approach:
- there is a common API that let me manage META
- modules that want to add META use it
- when everything is ready drupal_set_html_head get called

The problem is:
- the API functions should be ready when other modules call them
- drupal_set_html_head($meta) should be called last

If the weight of my meta module is high, other modules won't find
the functions.
If the weight of my module is low and I put
drupal_set_html_head($meta) in the menu hook, drupal_set_html_head
will be called before $meta had the chance to be filled by other
modules.

I'd say this is a general common problem but I didn't find any
"drupalish" way to solve it.

The easiest (and somehow elegant) way I thought to deal with this
problem was to build up 2 modules with different weight):
- meta_prepare (that will offer the functions)
- meta_deliver (that will simply call drupal_set_html_head)

Is there a more drupalish way to deal with dependency and "order of
execution" in drupal?

thanks

-- 
Ivan Sergio Borgonovo
http://www.webthatworks.it



More information about the support mailing list