[support] inter module communication, hooks and dependencies

Ivan Sergio Borgonovo mail at webthatworks.it
Fri Jan 2 16:42:39 UTC 2009


On Fri, 2 Jan 2009 09:56:13 -0500
"Shai Gluskin" <shai at content2zero.com> wrote:

> Hi Ivan,
> 
> I just looked over your post really quickly. But that quick glance
> makes me think you are need of one or both of the following
> modules in addition to nodewords:
> 
> http://drupal.org/project/nodewords_bypath
> http://drupal.org/project/nodewords_nodetype

I did really look in those modules but what I would like to overcome
is the need of "knowledge" by nodewords of the "content" that it is
going to be displayed (be it a node or "whatever").

What I was thinking is:
- having a global object that store what other modules would like to
see in the META (+ some logic to decide what actually get in)
- having some mechanism that when when all the module got a chance
to make a request to the global object will output the META

I could think of a hook mechanism that achieve this but it is not as
simple and elegant as having 2 modules with different weight:
- offering the object
- output the META

The hook mechanism I'm thinking about is not that different from the
one actually used by the above mentioned modules but it is
convoluted.

I may use nodewords_bypath to add a set of "static" keywords to
some content generated by a MENU_CALLBACK, but nodewords_bypath is
not aware of the additional information associated with the
MENU_CALLBACK that could be used to build up META.

So I may think that each module that would like to use nodewords
provide a hook that pass some info and then the module try to
"guess" which kind of content was being generated and add the
meta... but choosing the meta is something that should be contextual
to content creation... then an API may have a system to prioritise
which META actually get chosen.

So back again to the general problem: inter module communication,
hooks and dependencies...

In module world (out of core) the simplest thing I thought to
overcome the workflow/existence of global object problem was to have
2 modules with 2 different weights...

The first one will provide the global object (and methods), the
second one will trigger an action.

While it doesn't look terrible to actively use weights for 2 modules
to solve this problem there may be other systems already integrated
into drupal to deal with this kind of dependency.

Of course if what get into head (drupal_set_html_head()) was a
structured object rather than a string... I wouldn't have to think
to write a module so that each function can easily modify META...
but that's another topic...

If there is no core global object and core global workflow and I
need one... I wouldn't know how to build it in a module.
That's what I'd like to learn.

thanks

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



More information about the support mailing list