2

In Drupal 6 HEAD tags were part of the page.tpl.php. Now that that has moved to the html.tpl.php in D7, what is the correct way to create templates that need different data in head tags?

2

Use hook_preprocess_html ( e.g in template.php ) to modify the html.tpl.php variables.

For different JS or CSS, check the path ( e.g current_path() == 'foo' ) and add with

Set the 'every_page' option, and perhaps preprocess flag to FALSE.

| improve this answer | |
  • On a related note, could there be a performance issue here? Granted it would not be noticeable only one or two pages. But, if I needed several hundred templates, would it make a differece if these were statically embedded or called from template.php? – blue928 Jan 27 '13 at 22:46
  • If you need hundreds of templates or variations, you should probably rethink your design. – David Thomas Jan 27 '13 at 22:47
  • I have a classifieds website that has 100s of pages, each based on a taxonomy term. XML Sitemaps is configured to add each of these pages to my sitemap based on the included Sitemap taxonomy module. What I am wanting is to have each category listing have its own template so I can fine tune the head elements (meta, etc) for each of these term pages. Meta tags does not give me the control I need as it forces tokens to be applied unimformly across all taxonomy term listing pages. That's what I am trying to get around. Thoughts? – blue928 Jan 27 '13 at 23:53

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.