At Northern Pride, not only do we empower our clients with the ability to modify their web site pages, but to also easily edit their Cascading Style Sheets (CSS) using our North Star Content Management System. Being able to control a web sites CSS files from within a Content Management System makes it easy to change web site colors, fonts, page backgrounds, menu positions, alignments and so much more.
Recently, a client of ours which specializes in landscape management inquired about being able to change their web site background image with the seasons. This is a wonderful idea and great way to keep a site looking fresh and current. So, our graphic designers went to work designing four seasonal web site backgrounds and when completed we uploaded the images to our servers, that was the easy part. Next our developers wrote the code which would allow the CSS rules to be modified from within the Clients North Star Content Management System control panel. Lastly, we configured the server .htacess file and all css files to parse php in the css files.
Two Steps To Parse PHP In CSS
To run the (server-side) executable code in the CSS files you need to make Apache treat CSS files as PHP.
- Place the following directive code in a .htaccess file in the directory where the CSS file are stored. Depending on your server configuration, one of the 2 directive codes below should do the trick.
AddType application/x-httpd-php .css
AddHandler application/x-httpd-php .css
- Add the following code to the top of ALL of your css files located in the folder or subfolders where you uploaded the .htaccess file, even if you don’t use PHP within them!
<?php header("Content-type: text/css"); ?>
That’s it. You are ready to start adding php code into your css files. Being able to process php code in css files eliminates the need for maintaining duplicate css files and makes it much easier to manage your web site.
So if you would like greater flexibility with your web site, and want the ability to change your site backgrounds, site colors, heading fonts, menu positions, or anything else on your web site that is currently defined in your css files, ask your webmaster to “Incorporate PHP in your CSS, and then add it to your CMS”. If your webmaster acts clueless to what you just requested, give us a call and we will be happy to add our North Star CMS to your web site and give you the control you deserve. With the right code anything is possible!