php snippet

22 Oct 2003

I’ve found the PHP stylesheet switcher from ALA immensely useful, as it also opens up an easy way to provide different content, depending on the style chosen.

For example, to make sure that the navigation is displayed ‘flat’ in the diet version of hicksdesign (by removing the javascript), I’ve used the following php snippet:


<?php
  if ($sitestyle=="plain") 
  echo 
  "<script type=\"text/javascript\" src=\"/js/global_plain.js\"></script>"; 
  else echo 
  "<script type=\"text/javascript\" src=\"/js/global.js\"></script>";
?>

If ‘plain’ has been chosen by the user, it inserts the link to an external javascript file containing no menu scripts. If the user has chosen the default, or not chosen at all, it inserts the link to the version that has. (This won’t work in Mozilla if the user changes style using the browser menu). Using the css property display:none will just hide it from view, but this means you can decide what content goes into the HTML before it actually gets to the user.

Recent Posts

Differences between Icon and Logo Design on This is HCD Podcast

10 Apr 2018

Twelve South PencilSnap

01 Apr 2018

The Infinite Canvas

09 Feb 2018

Blade Runner 2049

14 Oct 2017

iPad Pro Pencil loop

11 Oct 2017

Troika #32: Tearjerker

04 Oct 2017

Instagram Hickstagram

  • 25 Apr 2018

    Haven’t done a sunset in a while, and tonight’s was too good to ignore

  • 23 Apr 2018

    Your birthday pavlova awaits you @hicksleigh!

  • 23 Apr 2018

    A very Happy Birthday to my lovely wife Leigh! We’re keeping the age a secret a though…

  • 18 Apr 2018

    Kind of them to notice!

  • 18 Apr 2018

    A very Happy 20th Anniversary to @hicksleigh! I love you more than ever wifey, and still thank my lucky stars that we met. 😘😍

  • 16 Apr 2018

    If anyone’s interested in buying a nice carbon road bike, I’m selling my Colnago 😉 https://www.ebay.co.uk/itm/Colnago-CLX-3-0-2012-carbon-road-bike-size-54/302705911235

  • 15 Apr 2018

    So pretty!

  • 13 Apr 2018

    Tasty one this

  • 10 Apr 2018

    Replacing worn out MacBook keys. I obviously type ‘a’ a lot

  • 08 Apr 2018

    Grown up Fanta

Contact us

Call Jon on +44 (0)7917 391536, email or tweet @hicksdesign.

Alternatively, pop in for tea and cake at the studio…

Hicks
Wenrisc House
Meadow Court
Witney, OX28 6ER
United Kingdom