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 releasing this script for a free download, and later on I will make a few PHP Tutorials for beginners based on this sript I made. I am actually thinking of making some screencasts as well. Okay, but for now – lets stick to the script.
- 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.
- Automatically sets a default CSS File in this order:
- Look for style.css to set as default
- If not found, look for default.css
- 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.
- Download the script
- 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)
- In the site <head> insert something like this:
<link rel="stylesheet" type="text/css" href="css/switch.php">
Bugs & Bugfixes
v0.2 – 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 )
- 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!