saadsalman Posted October 10, 2008 Share Posted October 10, 2008 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! 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted October 10, 2008 Share Posted October 10, 2008 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? yes you can put php in the templates - read the smarty manual 0 Quote Link to comment Share on other sites More sharing options...
saadsalman Posted October 10, 2008 Author Share Posted October 10, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted October 10, 2008 Share Posted October 10, 2008 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? 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted October 10, 2008 Share Posted October 10, 2008 um, why not use regular html conditional statements? like: <!--[if IE 6]>Special instructions for IE 6 here <![endif]--> 0 Quote Link to comment Share on other sites More sharing options...
saadsalman Posted October 10, 2008 Author Share Posted October 10, 2008 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! 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted October 10, 2008 Share Posted October 10, 2008 The $log_version is the output of eregi function in I should have looked closer... of course it does 0 Quote Link to comment Share on other sites More sharing options...
Ado Posted November 4, 2008 Share Posted November 4, 2008 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 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.