Forum Moderators: coopster
Today I asked myself a simple question that could save me a lot of time coding CSS styles. However, this question might be a little dumb. I'm not familiar with all the powerful capabilities of PHP, so I figured out I should just ask here.
Is it possible to create a dynamic CSS file using PHP, for instance this:
themes.css.php
- This .css file would have many many styles, but instead of placing "color: (some color here)" all over it, I would just have something like "color: <?php echo $rsThemes['ThemeColor'];?>". That means I can just pull out of the database any theme color I want for this particular CSS file and have that color changed in seconds.
- The final output with the query strings would look something like themes.css.php?ThemeColor=black. What this would do have all the colors set as black.
So, looking at my example could you guys tell me if it is possible or not to have this "dynamic CSS file" or is this just in my imagination?
Thank you for your help and have a great new year.
As then you can call your css script using
themes.css.php?ThemeColor=black
You would use statements like -
color:$_GET['ThemeColor'];
// or if you dont know what you may be setting
if ($_GET['ThemeColor']) {
color:$_GET['ThemeColor'];
}
else { // set a default color
color:fff;
}
You will also need to make sure that you send a
header('Content-Type: text/css; charset: UTF-8');