I'm trying to use a plugin I found for Smarty - but no matter what I do - I can't get it to work within an X-cart template:
Code:
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty {ie_detect} function plugin
*
* Type: function
* Name: ie_detect
* Date: 2.10.2004
* Purpose: Detect IE browser
* Input:
*
* Example:
* {ie_detect}
* {if $ie}
* <link rel="stylesheet" type="text/css" href="only-ie.css" />
* {else}
* <link rel="stylesheet" type="text/css" href="not-ie.css" />
* {/if}
* @link http://smartbee.sourceforge.net/
* @author Martin Konicek <martin_konicek@centrum.cz>
* @version 1.0
* @param null
* @param Smarty
* @return boolen
*/
function smarty_function_ie_detect($params, &$smarty)
{
$ie = strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE') ? true : false;
$ie = strpos($_SERVER["HTTP_USER_AGENT"], 'Opera') ? false : $ie;
if($ie){
$smarty->assign('ie', true);
} else {
$smarty->assign('ie', false);
}
}
/* vim: set expandtab: */
?>
This is the plugin code which I placed into function.detect_ie.php into the smarty plugin directory...
into the head template I placed:
Code:
{ie_detect}
{if $ie}
<link rel="stylesheet" type="text/css" href="only-ie.css" />
{else}
<link rel="stylesheet" type="text/css" href="not-ie.css" />
{/if}
No matter how I tweak the code I can never get the $ie to return true or false... I know the plugin is being called - because I hardcoded
Just:
Code:
$smarty->assign('ie', "Is this working?");
And of course I was able to print it out on the template...
For some reason it's as though the $_SERVER["HTTP_USER_AGENT"] isn't functioning...
Can anyone give me code for a working IE detector?
Thank you so much!
-Ripbud