CSS Switch v.0.3

I took a look around and decided that I am going to make a tiny free PHP Script – a CSS style switcher for designers. I am making this script for a free to download and use.

Functionality:

  • No PHP Knowledge required at all, No installing, just drop the file in your CSS Folder, and make sure the server supports PHP.
  • Ideal to showcase your work in multiple stylesheets but one HTML File.
  • Faster than JavaScript method and works with browsers who don’t have JS enabled
  • Automatically sets a default CSS File in this order:
    1. Look for style.css to set as default
    2. If not found, look for default.css
    3. If not found scan the directory for CSS files and use the first one found (ordered alphabetically)
  • Use Links to change styles. So <a href=”css/switch.php?style=another.css”>Another Style</a> is going to switch the style, set a cookie for 1 hour and then redirect back to last page. If last page visited can’t be found (HTTP_REFERER) PHP script will redirect back to index of the site.

Setup

  1. Download the script
  2. Insert switch.php to your CSS Folder (In best scenario, you have a seperate folder with CSS files, if not, it’s okay, the script filters CSS files when listing them)
  3. In the site <head> insert something like this:

Bugs & Bugfixes

v0.3 – Added a feature to reload back to site domain if HTTP_REFERER Not found
v0.2 – Fixed Stylesheet file format. Now works with all HTML Versions. (php header content type changed to text/css )

Future Features

  • GZipped output (faster load times)
  • Optimization if needed
  • Support for multiple CSS files at once (so multiple CSS files would be included with a single request, just in case someone needs that 🙂 )

I hope you enjoy the script!

And now you can either see it in action or download it!

 

[button url=”http://demo.themer.me/css/” style=”green” size=”large”] See the demo [/button] OR [button url=”https://github.com/justnorris/CSS-Style-Switcher” style=”orange” size=”large”]Download Switcher PHP Script[/button]

17 comments

  1. Hello,

    Thank you verry much!

    Ive been trying to get something like this to work for almost a day using two other tutorials. But those methods failed to set a cookie.

    This script is easy to setup and works for me.

    I do have one problem, when i go to mi website the first time in a session mi page is broken. When i refresh the page it turns to normal.

    Any idea why this happens?

  2. I fixed it 🙂

    I linked mi default css file before i call the script, now the default theme is showing when you visit the website and switching themes still works.

    Thx again!

  3. I love the idea of this script but your links are dead 🙁
    Any chance of another location???
    I really wanna see what this thing can do.
    Thanks

  4. This is a great script. There are many PHP switchers out there, and half of them haven’t worked for me (as I am not that versed in PHP) however this seems to have worked first time.

    Great work.

Leave a Reply

Your email address will not be published. Required fields are marked *