Hola folks! I will try to be as clear as possible... if I am not, please ask me to clarify. Ok, here it goes:
Here is my CSS PHP code:
Code: Select all
<?php
//file name: optional_css.php
('Content-type: text/css');
function css_color($link)
{
$pages = array ("Home" => "home.php", "About" => "about.php", "Folio" => "folio.php", "Resume" => "resume.php", "Code" => "code.php", "Forum" => "forum.php", "Contact" => "contact.php", "Links" => "links.php");
$page_colors = array ("Home" => "#0066cc", "About" => "#0066ff", "Folio" => "#009988", "Resume" => "#6666cc", "Code" => "#006622", "Forum" => "#cccccc", "Contact" => "#009999", "Links" => "#000000");
$my_colors = $page_colors[$link];
$page = str_replace("/", "", $_SERVER['SCRIPT_NAME']);
if($page == $pages[$link]) {
echo "$my_colors";
} else {
;
}
}
?>
body {
background-color: <? css_color("Home"); css_color("About"); css_color("Folio"); css_color("Resume"); css_color("Code"); css_color("Forum"); css_color("Contact"); css_color("Links"); ?>;
}Code: Select all
<style type="text/css" media="screen"> @import "css/optional_css.php"; </style>The above code works if I change it to this (but is not (as) dynamic):
Code: Select all
<?php
header('Content-type: text/css');
$color1 = "#FF0000";
?>
body {
background-color: <? echo $color1; ?>;
}When it comes to the first block of code (one with function), am I doing things right? I know that the basic syntax of my function "function css_color($link)" works for other dynamic parts of my code (Current Menu Linkage, Dynamic Loading Header Content...)
The only suggestion I have recieved so far (from other forum) is this:
Can someone elaborate on the above quote for me? I think I get it, but I am having troubles writing the algorithm.The css file is loaded into cache. How you would do this is to define seperate classes for different colors, then reference the class you want in your dynamic php code.
Any suggestion?
Any help would be greatly appreciated.
Thanks in advance.
Cheers
Micky