Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Change background according to season

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 09-10-2012, 06:37 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default 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}
__________________
xcartmods.co.uk
Reply With Quote

The following 4 users thank PhilJ for this useful post:
ADDISON (09-10-2012), cherie (09-10-2012), jacob1978 (04-23-2013), wendy.email (09-10-2012)
  #2  
Old 09-10-2012, 06:50 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default Re: Change background according to season

Very funny. Thanks my friend. Christmas is coming!
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote

The following user thanks ADDISON for this useful post:
PhilJ (09-10-2012)
  #3  
Old 09-10-2012, 06:59 AM
 
wendy.email wendy.email is offline
 

Advanced Member
  
Join Date: Jun 2005
Location: Canada
Posts: 90
 

Default Re: Change background according to season

exactly what i've been looking for... thanks!
__________________
Version 4.1.11
Reply With Quote

The following user thanks wendy.email for this useful post:
PhilJ (09-10-2012)
  #4  
Old 09-10-2012, 07:11 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default 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.
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote

The following user thanks ADDISON for this useful post:
PhilJ (09-10-2012)
  #5  
Old 09-10-2012, 09:21 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default 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.
__________________
xcartmods.co.uk
Reply With Quote

The following user thanks PhilJ for this useful post:
ADDISON (09-10-2012)
  #6  
Old 09-10-2012, 12:55 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default 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"
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote

The following 2 users thank cherie for this useful post:
ADDISON (09-10-2012), PhilJ (09-10-2012)
  #7  
Old 09-10-2012, 01:18 PM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Change background according to season

Pure Smarty version added
__________________
xcartmods.co.uk
Reply With Quote

The following user thanks PhilJ for this useful post:
ADDISON (09-10-2012)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:55 AM.

   

 
X-Cart forums © 2001-2020