From API: http://api.drupal.org/api/function/hook_footer/6

Insert closing HTML.

This hook enables modules to insert HTML just before the \ closing tag of web pages. This is useful for adding JavaScript code to the footer and for outputting debug information. It is not possible to add JavaScript to the header at this point, and developers wishing to do so should use hook_init() instead.

So this ...

/**
 *  Invoke the plugin on any page listed from the configuration page.
 *  Code swiped from block_list
 */
function jquery_media_footer() {
  $path = drupal_get_path_alias($_GET['q']);
  $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote(variable_get('jquery_media_pages', ''), '/')) .')$/';
  // Compare with the internal and path alias (if any).
  $page_match = preg_match($regexp, $path);
  if ($path != $_GET['q']) {
    $page_match = $page_match || preg_match($regexp, $_GET['q']);
  }
  if ($page_match) {
    jquery_media_add();
  }
}

should be...

/**
 *  Invoke the plugin on any page listed from the configuration page.
 *  Code swiped from block_list
 */
function jquery_media_init() {
  $path = drupal_get_path_alias($_GET['q']);
  $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote(variable_get('jquery_media_pages', ''), '/')) .')$/';
  // Compare with the internal and path alias (if any).
  $page_match = preg_match($regexp, $path);
  if ($path != $_GET['q']) {
    $page_match = $page_match || preg_match($regexp, $_GET['q']);
  }
  if ($page_match) {
    jquery_media_add();
  }
}
CommentFileSizeAuthor
#1 jquery_media-hook_footer-862540-1.patch674 bytesmdupont

Comments

mdupont’s picture

Assigned: Unassigned » mdupont
Status: Active » Needs review
StatusFileSize
new674 bytes

I've just stumbled upon this issue while trying to make jquery_media work on a View of nodes. It was working when viewing the full node (as per jquery_media_nodeapi()) but on the view the js wasn't added, even if the path was added to the settings.

All I had to do to make it work was to switch hook_footer() to hook_init() (which is a standard way to add js files to pages). Patch attached, please review.