karmatiger Posted July 31, 2013 Share Posted July 31, 2013 I use a css sheet that's actually .php so I can make cascading changes easily (style.php) e.g. a {color: <?php echo $AccentColor1 ?>;} The colours are set in a separate file with an include command (colours.php). They're typically directly assigned, e.g. $AccentColour2 = "#efefef" One colour (and possibly more once I get this to work) is stored in a database and retrieved by $Main_colour. When I echo $Main_colour it shows the expected value, (in this case #a9100c). Here's where the problem arises... If I put $AccentColour1 = "#a9100c"; in colours.php, the css in style.php works and everything that is meant to be that colour IS that colour. However, if I put $AccentColour1 = $Main_colour; in colours.php, even though the main_colour variable displays the expected value when echoed, the css breaks and everything that is meant to be that colour comes out link blue. It gets even more strange. If I put $TempVar = #cdcd57; $AccentColor1 = $TempVar; $AccentColor1 = $Main_colour; the css works but everything that's meant to be #a9100c comes out as #cdcd57 instead... EVEN THOUGH both $AccentColor1 and $Main_colour echo as #a9100c before and after the css is processed. Why is the css refusing to accept $AccentColor1 = $Main_colour? Quote Link to comment Share on other sites More sharing options...
fastsol Posted July 31, 2013 Share Posted July 31, 2013 Have yo uactually verified that the output on the style sheet is what you expect it to be, or are you judging it by a simple refresh and not seeing the chagnes on the screen? It might be a chache issue. Second, in the code examples above you go back and forth between $AccentColor1 and $AccentColour1, notice the u difference in the name. Make sure you have all you vars labeled correctly. Quote Link to comment Share on other sites More sharing options...
karmatiger Posted July 31, 2013 Author Share Posted July 31, 2013 I also manually change it using conventional hex values put into $Accentcolor1 and it works, so unlikely a cache issue. The variable names are uniform in the code; I just had a typo in my post above. Here's another weird thing: If I put: if (isset($Main_colour)) { $AccentColor1 = "#a9100c"; } else $AccentColor1 = "#000000";echo $AccentColor1; ...it prints #a9100c, indicating $MainColour is set, and therefore $Accentcolor1 = #a9100c. Right?but when it gets to the CSS...a color: <?php echo $AccentColor1 ?>;}...with no instance of $accentcolor1 in between so it shouldn't be redefined, it thinks $AccentColor1 = #000000. It still echoes it as #a9100c before and after, but colours the links as #000000. Quote Link to comment Share on other sites More sharing options...
fastsol Posted August 1, 2013 Share Posted August 1, 2013 If you use firefox or chrome browsers you can use firebug in firefox to see what css rules are being applied to a specific element in the browser. Most likely you have a different css rule that is overriding it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.