Jump to content

Different templates for different browsers


saadsalman

Recommended Posts

Hi all,

 

In my website template I need to put a few CSS hacks for Internet Explorer and hence include a iehack.css in the html if the browser is IE.

 

Currently I am doing it with a small php code but how can I implement that in the tpl files? Can I put php code in it?

 

Any help would be highly appreciated!

Link to comment
Share on other sites

I would be thankful if someone could transform this short code into a smarty one, i would need to learn smarty from scratch for this work! :?

 

<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if (eregi( 'MSIE ([0-9].[0-9]{1,2})',$agent,$log_version)) {
include 'iehacks.css'; //must be included for any version of IE
if (strpos($log_version[1],'7.') !== false) {
	include 'ie7hacks.css';  //additional include for IE 7
}
elseif (strpos($log_version[1],'6.') !== false) {
	include 'ie6hacks.css';  //additional include for IE 6
}
elseif (strpos($log_version[1],'5.') !== false) {
	include 'ie5hacks.css';  //additional include for IE 5
}
}
?>

 

I would be really thankful for any help :)

Link to comment
Share on other sites

Doesn't need much. The easiest way is just to use {php}...{/php} tags in your header.tpl within the <head>...</head> section like

 

{php}

$agent = $_SERVER['HTTP_USER_AGENT'];

if (eregi( 'MSIE ([0-9].[0-9]{1,2})',$agent,$log_version)) {

include 'iehacks.css'; //must be included for any version of IE

if (strpos($log_version[1],'7.') !== false) {

include 'ie7hacks.css'; //additional include for IE 7

}

elseif (strpos($log_version[1],'6.') !== false) {

include 'ie6hacks.css'; //additional include for IE 6

}

elseif (strpos($log_version[1],'5.') !== false) {

include 'ie5hacks.css'; //additional include for IE 5

}

}

{/php}

don't forget about the normal css include already in the header.tpl.

 

Also where is $log_version being set?

Link to comment
Share on other sites

Doesn't need much. The easiest way is just to use {php}...{/php} tags in your header.tpl within the <head>...</head> section like

 

don't forget about the normal css include already in the header.tpl.

 

Also where is $log_version being set?

 

Oh it was so simple!

 

The $log_version is the output of eregi function in

eregi( 'MSIE ([0-9].[0-9]{1,2})',$agent,$log_version)

 

Thanks once again!

Link to comment
Share on other sites

  • 4 weeks later...

Hi,

I use this in my style.css:

 

html {overflow-y: scroll;

}

 

This displays the right hand browser bar by default even if each page does not extend to the point a scrollbar is needed. This helps to match the templates both in IE and Firefox as by default IE will not display a scrollbar putting the template out 10 pixels. Hope this is of some help.

 

-Ado

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated