Drupal 6: using template based on browser version Is it possible to serve up a specific page template based on browser version? If I can satisfy my IE 7 requirements with a special template, I'd prefer that rather than loading a bunch of extra css only used when IE7 is being used.

I have a special drop-down menu and though on its own will work in IE7, once it's a block and assigned to a region, issues start with height. I can put it in another region within a page template but then I'm changing all the css for all other browsers so I'd just as soon as have a template for the specific pages.

thanks
Normally that would be done with conditional css e.g. conditional_styles and that approach is recommended first.

Mainly because why change the entire template when only the CSS needs changing?

However, if you really need separate tpls ( e.g for new HTML markup ), you could probably use template suggestions in hook_preprocess_page after checking the browser user agent.

Something like this in template.php

/**
 * Implements hook_preprocess_page
 */
THEMENAME_preprocess_page(&amp;$variables){
  // Requires browscap.ini, check PHP docs for details, else use $_SERVER['HTTP_USER_AGENT']
  $browser = get_browser();
  if($browser-&gt;browser == 'IE' &amp;&amp; $browser-&gt;majorver == 7) {
    $variables['template_files'][] = 'page-ie7';
  }
}


After clearing all caches, you could then use page-ie7.tpl.php for IE7.

See the note on http://php.net/manual/en/function.get-browser.php for info else use $_SERVER['HTTP_USER_AGENT'] to check browser from request. You'll also need to make sure your cache varies on user agent as well.