[support] inter module communication, hooks and dependencies
Pierre Rineau
pierre.rineau at makina-corpus.com
Fri Jan 2 19:21:03 UTC 2009
I think this is a good idea.
This will let each module set it's own meta keywords and stuffs, like JS
aggregation with drupal_add_js(), something like a meta aggregator hook
or function would be great.
On Fri, 2009-01-02 at 10:56 -0600, Larry Garfield wrote:
> On Fri, 2 Jan 2009 17:42:39 +0100, Ivan Sergio Borgonovo <mail at webthatworks.it> wrote:
>
> > 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
>
> I'd say you're on the right track with a hook. It's probably easier to explain with examples. I'd suggest something like:
>
> hook_meta() {
> $info['keyword'] = array('foo', 'bar');
>
> $info['some_key'] = 'some value';
>
> return $info;
> }
>
> hook_meta_alter() {
> // Because when you have a structured array, an alter hook is so dead simple to add it seems pointless not to.
> }
>
> yourmodule_preprocess_page(&$vars) {
> // Invoke hook_meta_info() and the alter hook, get back the data from all modules,
> // format it, and inject it into the $vars['head'] variable as appropriate.
> }
>
> Modules that need to do complex logic to figure out what tags to add can do so in their own hook_meta implementations. It also means no module has a hard-dependency on your module or vice versa, weight doesn't matter, and other modules can inject whatever meta tag info they need that you haven't thought of before.
>
> Make sense? (Exact implementation is left as an exercise for the implementer.)
>
> --Larry Garfield
>
More information about the support
mailing list