Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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;
}
Comment | File | Size | Author |
---|---|---|---|
omniture.module.patch | 517 bytes | jwhat | |
Comments
Comment #1
Race.it CreditAttribution: Race.it commentedI 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.
Comment #2
jwhat CreditAttribution: jwhat commentedIn 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.
Comment #3
jwhat CreditAttribution: jwhat commentedComment #4
Race.it CreditAttribution: Race.it commentedWould 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.