WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • automatically change the templates css on a specified date
  • Print
Pages: [1]   Go Down

Author Topic: automatically change the templates css on a specified date  (Read 3940 times)

snark

  • Guest
automatically change the templates css on a specified date
« on: December 12, 2009, 03:37:53 PM »
I want to automatically change the css code for a website on for instance x mas, new years day, easter, etc

I found this but I would really like it if I can specify a day of the month, I presume it is quite simple but I am way to dumb ...

Code: [Select]
    <link rel="stylesheet" type="text/css" href="default.css" id="siteCSS"/>
    <script type="text/javascript">

        // Get current month
        var currDate=new Date();
        var currMonth = currDate.getDate();

        // Month returned by getDate() is 0 to 11 so add 1
        currMonth = parseInt(currMonth) + 1;

        // Based on month assign style sheet name
        var newCSS = "default.css";
        if (currMonth >= 1) newCSS = "winter.css"; // Month is January or greater
        if (currMonth >= 3) newCSS = 'spring.css'; // Month is March or greater
        if (currMonth >= 6) newCSS = 'summer.css'; // Month is June or greater
        if (currMonth >= 9) newCSS = 'fall.css';   // Month is September or greater
        if (currMonth = 12) newCSS = 'winter.css'; // Month is December

        // Assign new style sheet name as the new href for "siteCSS" LINK tag
        document.getElementById('siteCSS').href = newCSS;

    </script>

Logged

mr-fan

  • Guest
Re: automatically change the templates css on a specified date
« Reply #1 on: December 12, 2009, 03:43:49 PM »
hi snark....don't use JS if you can use PHP  :wink:

i would it try like this:

Code: [Select]
<?php //colour your life
if ((date(&#39;m&#39;) == 12) || ((date(&#39;m&#39;) == 1) && (date(&#39;d&#39;) < 7))) {
echo &#39;<link rel="stylesheet" type="text/css" href="winter.css" id="siteCSS"/>&#39;;
}else{
eche &#39; <link rel="stylesheet" type="text/css" href="default.css" id="siteCSS"/>&#39;;
}

or make it with a switch call for all four seasons...

dont' tested...

regards martin
Logged

snark

  • Guest
Re: automatically change the templates css on a specified date
« Reply #2 on: December 12, 2009, 05:37:28 PM »
ahhh thank you very much nr fan

this was exactly the anwser I was hoping for, for everyone that needs more options...

Code: [Select]
<?php
if ((date(&#39;m&#39;) == 12) && (date(&#39;d&#39;) > 4) || ((date(&#39;m&#39;) == 12) && (date(&#39;d&#39;) < 6))) {
echo &#39;sinterklaas&#39;;

}else if ((date(&#39;m&#39;) == 12) && (date(&#39;d&#39;) > 25 || ((date(&#39;m&#39;) == 1) && (date(&#39;d&#39;) < 28))) {
echo &#39;kerst&#39;;


}else{
echo &
#39;geen sinterklaas, geen kerst&#39;;
}

?>
« Last Edit: December 12, 2009, 06:27:33 PM by snark »
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • automatically change the templates css on a specified date
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2