php snippet

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:

      if ($sitestyle=="plain")
      "<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.