php in css?
Moderator: General Moderators
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
php in css?
I have style.css and I use it through my whole site, but I want to be able to change colors and table sizes in the style sheet through a admin section. Now how should I go about doing this? Would it be best to make it all in a db and save the css file as style.php and have the values of the colors and widths as fields in the database that can be updated or should i try to directly write to the file. Also, is it even possible to make a css sheet with variables like that? Im not quite sure how I should go about doing this so any ideas would be great.
It is very possible to put PHP fields in CSS
For example, here is my CSS for a portion of my site.
Hope this helps you.
For example, here is my CSS for a portion of my site.
Code: Select all
<style type="text/css">
a:link { font-weight: bold; color: #<? if ($rowї"linktextcolor"]) { echo "$rowїlinktextcolor]"; } else { echo "000000"; } ?>; text-decoration: none; font-size: 13px; font-family: times new roman, arial; }
a:visited { font-weight: bold; color: #<? if ($rowї"linktextcolor"]) { echo "$rowїlinktextcolor]"; } else { echo "000000"; } ?>; text-decoration: none; font-size: 13px; font-family: times new roman, arial; }
a:hover { font-weight: bold; color: #<? if ($rowї"linktextcolor"]) { echo "$rowїlinktextcolor]"; } else { echo "000000"; } ?>; text-decoration: underline; font-size: 13px; font-family: times new roman, arial; }
a:active { font-weight: bold; color: #<? if ($rowї"linktextcolor"]) { echo "$rowїlinktextcolor]"; } else { echo "000000"; } ?>; text-decoration: none; font-size: 13px; font-family: times new roman, arial; }
body { font-size: 15px; color: #<? if ($rowї"textcolor"]) { echo "$rowїtextcolor]"; } else { echo "000000"; } ?>; font-family: times new roman, arial; }http://www.selfphp.com/
Look for the functions
Then try to find a pattern in your css code
Look for the functions
Code: Select all
fopen()
fclose()
fgets()
substr()- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
Yes I could just rewrite the file but thats getting a little complicated and when I have somthing like
I want to be able to use a db to have multiple skins that i can just change with a simple form but any ideas on how to do this all without having extream amounts of fields in my db table because i cant think of any other way except making each color and text decoration a seperate field? using another db would organize it a lot but that is not a option. any sugestions?
Code: Select all
#forums, table.posts, #profile { border-collapse: collapse; font: .9em Verdana, Arial, sans-serif; width: 100%; }
#forums, #forums th, #forums td { border: 1px solid #805E40; }
#forums th, table.posts th { background: #E6BD73; font-size: .9em; }
#forums th { color:#000; padding: .25em; }
#forums td, table.posts td { background: #FFE3BF; }
#forums td { padding: .5em; }
#forums .category { background: #FFD280; color: #000; font-weight: bold; padding: .3em; }
#forums .type { padding: 0 .25em 0 .3em; }
#forums .name { text-align: left; width: 100%; }
#forums .author, #forums .topics, #forums .posts { text-align: center; }
#forums .author { white-space: nowrap; }
#forums td.lastpost, #forums td.lastpostlink { font-size: 0.8em; }
#forums th.lastpost, #forums td.lastpost { white-space: nowrap; }
#forums span.desc { color: #899; font-size: 0.9em; }
#forums span.modlinks { float: right; font-size: 0.75em; }
#forums span.modlinks a { color: #344; text-decoration: none; }
#forums span.modlinks a:hover { background: none; color: #566; }
#forums span.authortitle { font-size: 0.9em; color: #BF9D60; }
#forums .postauthor { width: 13em; }
#forums td.postauthor { padding-bottom: 1em; }
#forums td.postauthor, #forums td.posttext { vertical-align: top; }