On line 122 of omniture.module, I added $header and $footer as follows:

if ($omniture_hooked_vars = module_invoke_all('omniture_variables', $main, $header, $footer)) {

Now I am able to append, prepend and manipulate the $header and $footer values as needed from within my custom method, like so:

function myhelper_omniture_variables($main, $header, $footer) {

  $data = array();

  // Add the Omniture account variable that's been abstracted from Omniture's JS code to the beginning of $header, if it exists.
  // Note: I added 'omniture_account' as a variable in this module since I've removed it from the s_code.js file.
  if ($s_account = variable_get('omniture_account', false)) {
    $data['header'] = '<script type="text/javascript" language="JavaScript">' . PHP_EOL
      . 'var s_account = "' . $s_account . '";' . PHP_EOL
      . '</script>' . PHP_EOL
      . $header;
  }

  // Add some more useful code to the end of $header.
  $data['header'] .= 'more useful code';

  // Add some useful code to the beginning of $footer as well as the end of $footer.
  $data['footer'] = 'useful code ' . PHP_EOL . $footer . PHP_EOL . ' more useful code at the end';

  return $data;
}
CommentFileSizeAuthor
omniture.module.patch517 bytesjwhat
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Race.it’s picture

Status: Needs review » Postponed (maintainer needs more info)

I do not understand the need for this patch, as it stands the module kicks out the header, omniture_variables, then footer in that order, so why would you not just stick your omniture account variable inside the main set of variables.

If you know of a reason why the header and footer would need to be appended to please can you state this reason.

jwhat’s picture

In this specific case, s_account is referenced in s_code.js, therefore it needs to exist before the JS include.

I find it useful to have full control over $header and $footer despite the simple need for it in this case.

jwhat’s picture

Status: Postponed (maintainer needs more info) » Needs review
Race.it’s picture

Would you not just have your own module that set the relevant variables before the omniture module was called, then your module would deal with the value being set, and you would introduce a dependancy on the new module to this omniture module.