I've been thinking about how we do variables and I think a hook is a horrible idea. Or at least an incomplete one.

In general...a module serving up a specific page looks like this:


foo_menu() {
  // Menu declaration pointing to foo_page() as the callback.
}

foo_page() {
  // Do some stuff.
  // This knows the context it's on, because it defines it.
  // Do more stuff.
  return $stuff;
}

foo_omniture_variables() {
  // This has to try to determine the context with menu_get_object or arg() or get_context().
  // And then build up the variables with data that was probably available in foo_page()
  // And ultimateley, return stuff.
}

It would be so much easier if foo_page() could call something like omniture_set_variables($variables) and omniture would just store those up in a static or a session variable and ultimately they would get spit out.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Race.it’s picture

Think this is a good idea, what I would say is the hook mechanism that we have at present is good and we should aim to keep this, but also if we implement this other method (would this be nodeapi hook?) so the user of the module can also choose.

greggles’s picture

Title: change to a push mechanism rather than a poll mechanism for variables » change to a push mechanism in addition to the poll mechanism for variables
Status: Active » Needs review
FileSize
5.2 KB

So, I finished this and also fixed an issue where the hook_omniture_variables could get broken by two modules that return values for the same key. I had to make some decisions about weighting.

If two modules provide different values for the same key, what should we do? I decided that the heaviest module should win - i.e. we use the value from the module with a heavier weight.

If a module provides a variable via omniture_set_variable does that take precedence over the hook mechanism? I say yes. For no particular reason :)

greggles’s picture

Title: change to a push mechanism in addition to the poll mechanism for variables » Add a push mechanism in addition to the poll mechanism for variables
Status: Needs review » Fixed

And fixed - http://drupal.org/cvs?commit=266922

I'm starting to think that if we fix a few other patches it's time to make a 6.x-2.0 release. What do you guys think?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.