X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Passing users screen resolution through as a variable (https://forum.x-cart.com/showthread.php?t=23754)

weckie 08-01-2006 03:02 PM

Passing users screen resolution through as a variable
 
I need users screen width as a variable in an tpl file.

FI. {if $var eq "1024"}Do This{else}DO THAT{/if}


Can this be done?

balinor 08-02-2006 03:24 AM

JavaScript is your best bet:

http://www.pageresource.com/jscript/jscreen.htm

weckie 08-02-2006 04:33 AM

hi balinor,

I know, but how do it pass the javascript var through to smarty (as a smarty var)

lachild 08-09-2006 02:57 PM

According to the documentation you should be able to pass this to the script...

Code:

<SCRIPT language="JavaScript">
<!--
if ((screen.width>=1024) && (screen.height>=768))
{
 window.location="home.php?res=high";
}
else
{
  window.location="lowres.html?res=low";
}
//-->
</SCRIPT>


Then what I would do is right above this line in home.php

Code:

#
# Assign Smarty variables and show template
#

$smarty->assign("main","catalog");


I might write something like this:

Code:

$res = $_GET['res'];

$smarty->assign("res", $res);


Then you should be able to use...

{if $res eq 'high'}
Some Code Here
{else}
Some More code Here
{/if}

weckie 08-10-2006 01:35 AM

thanks,

i will try it later today....


All times are GMT -8. The time now is 06:37 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.