Forum Moderators: coopster
Question 1: How can I load CSS definitions in the PHP script without having to modify the header section os the target page?
Secondly, the calendar is displayed in different styles on different pages by setting a variable before the include() call. Each of the four styles uses a different CSS file.
Question 2: How can I load different CSS layouts depending upon the value of a PHP variable?
Having spent two days on various experiments and drawing a blank, I would be more than grateful to anybody who can put me straight on these two issues.
To load the correct CSS markup in this fashion you could just use something like a switch [php.net]. Putting it all together ...
<?php
function callback($buffer)
{
global $css;
// update the CSS
return (str_replace("</head>", "$css\n</head>", $buffer));
}
ob_start [php.net]("callback");
?>
<html>
<body>
<p>It's like comparing apples to oranges.</p>
</body>
</html>
<?php
$myPHPvariable = 'two';
switch ($myPHPvariable) {
case 'one':
$css = '<link rel="stylesheet" type="text/css" media="all" href="/css1.css" />';
break;
case 'two':
$css = '<link rel="stylesheet" type="text/css" media="all" href="/css2.css" />';
break;
case 'three':
$css = '<link rel="stylesheet" type="text/css" media="all" href="/css3.css" />';
break;
default:
$css = '<link rel="stylesheet" type="text/css" media="all" href="/default.css" />';
break;
}
ob_end_flush();
?>