X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Change background according to season (https://forum.x-cart.com/showthread.php?t=64816)

PhilJ 09-10-2012 06:37 AM

Change background according to season
 
Just a simple little mod to change the background according to the season :)

Create your background images - winter.png / spring.png / summer.png / autumn.png

Upload your images to skin/common_files/images/seasons

( v4.3.x and below, upload to skin1/images/seasons )

Then add this code to the end of skin/common_files/service_head.tpl

( v4.3.x and below, add to skin1/customer/home.tpl before </head> )

Code:

{php}
$day = date("z");
if( $day < 79) $season = "winter";
elseif( $day < 171) $season = "spring";
elseif( $day < 265) $season = "summer";
elseif( $day < 354) $season = "autumn";
else $season = "winter";
{/php}
{literal}
<style type="text/css">body { background: {/literal}{$ImagesDir}{literal}/seasons/{php}echo $season{/php}.png center no-repeat; }</style>
{/literal}


Or, here's a pure Smarty version...

Code:

{assign var=day value=$smarty.now|date_format:"%j"} 
{if $day lt "79"}
{assign var=season value="winter"}
{elseif $day lt "171"}
{assign var=season value="spring"}
{elseif $day lt "265"}
{assign var=season value="summer"}
{elseif $day lt "354"}
{assign var=season value="autumn"}
{else}
{assign var=season value="winter"}
{/if}
{literal}
<style type="text/css">body { background: {/literal}{$ImagesDir}{literal}/seasons/{/literal}{$season}{literal}.png center no-repeat; }</style>
{/literal}


ADDISON 09-10-2012 06:50 AM

Re: Change background according to season
 
Very funny. Thanks my friend. Christmas is coming!

wendy.email 09-10-2012 06:59 AM

Re: Change background according to season
 
exactly what i've been looking for... thanks!

ADDISON 09-10-2012 07:11 AM

Re: Change background according to season
 
Please note starting with Smarty v3, {php}{/php} tag is deprecated. Those who use Smarty 3 patch supplied by qualiteam should know this is not working at all. You should make modification in php file then call the variable in template file.

PhilJ 09-10-2012 09:21 AM

Re: Change background according to season
 
Yes, but I'm guessing 99% of people haven't made the leap yet, due to it interfering with many mods.

cherie 09-10-2012 12:55 PM

Re: Change background according to season
 
Nice!

Seems you could avoid {php} and use something like this:

PHP Code:

{assign var=day value=$smarty.now|date_format:"%j"


PhilJ 09-10-2012 01:18 PM

Re: Change background according to season
 
Pure Smarty version added :)


All times are GMT -8. The time now is 12:08 AM.

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