-1

I am using "site map" module and I would like to add the following jQuery line so that the /sitemap page is formatted:

$('#mydiv').columnize({ width: 200 , columns: 3 });

The /sitemap page is not trapped within either hook_form_alter or hook_page_alter so how could I add this JQuery line?

3

The site_map module has a theme template implementation in the root folder of the module:

site-map.tpl.php

Easiest and most sustainable way to add this would be to copy this file to your theme templates folder, add your javascript in there and flush caches.

Other quick ways:

  • Create a block and add your javascript in there then place this in a region on the path '/sitemap'
  • Create your own preprocess_page module that adds this javascript if the path is /sitemap
  • so after copying the site-map.tpl.php file to my theme templates folder then an example of adding would be like the following correct? <?php drupal_add_js('jQuery().ready(function(){("#mydiv").columnize({ width: 200 , columns: 3 });});', 'inline'); ?> – John Mitchell Jul 15 '13 at 16:27
  • no - you would be better of adding it inline, using just html & script tags. you shouldn't modify the headers in a template file, if you want to do that add a preprocess_page function. – schnippy Jul 15 '13 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.