Drupal modules (ie. wysiwyg) asume that Javascripts with scope=footer are loaded after Javascripts with scope=header. Currently zentropy breaks this assumption.

By default header-JS goes into $script and footer-JS goes into $page_bottom. But zentropy's default html.tpl.php prints $script below $page_bottom.

function template_process_html(&$variables) {
  // Render page_top and page_bottom into top level variables.
  $variables['page_top'] = drupal_render($variables['page']['page_top']);
  $variables['page_bottom'] = drupal_render($variables['page']['page_bottom']);
  // Place the rendered HTML for the page body into a top level variable.
  $variables['page']              = $variables['page']['#children'];
  $variables['page_bottom'] .= drupal_get_js('footer');

  $variables['head']    = drupal_get_html_head();
  $variables['css']     = drupal_add_css();
  $variables['styles']  = drupal_get_css();
  $variables['scripts'] = drupal_get_js();
}

There is two possible ways to solve this:

  1. trust the modules to make the right choice and put $scripts in the header again.
  2. change process_html append the footer-Js to $scripts

Here is my implementation for 2.:

function zentropy_process_html(&$variables) {
        // Render page_top and page_bottom into top level variables.
        if (is_array($variables['page'])) {
          $variables['page_top']    = drupal_render($variables['page']['page_top']);
                $variables['page_bottom'] = drupal_render($variables['page']['page_bottom']);
                // Place the rendered HTML for the page body into a top level variable.
                $variables['page']              = $variables['page']['#children'];
        }

  $variables['head']    = drupal_get_html_head();
  $variables['css']     = drupal_add_css();
  $variables['styles']  = drupal_get_css();
  $variables['scripts'] = drupal_get_js() . drupal_get_js('footer');
}

?>

Comments

torotil’s picture

Ok, I forgot that template_process_html is executed before zentropy_process_html. Something like this would be better I guess:

function zentropy_process_html(&$variables) {
  $variables['scripts'] .= $variables['page_bottom'];
  $variables['page_bottom'] = '';
}

migueltrindade’s picture

Fixed in dev release.

torotil’s picture

Status: Active » Closed (fixed)

Now the scripts are all put into . This definitely fixes the problem.