Dynamic CSS

By orqi


CssController

Create a controller called “CssController.php” in your controller folder “_classes/_app”. You don’t HAVE to call it CssController of course, I’m only doing this because I find Css a memorable name for css stuff :D

class CssController extends Controller
{
	function Dynamic()
	{
		header("Content-type: text/css");
		$this->LoadTemplate("DynamicCSS");
	}
}

CSS Template

OK so we put a file “DynamicCSS.php” in our templates directory “_classes/_ui/_pc” like so …

h1
{
background: url(<?=$this->config->resource['img']?>/header.gif) left top no-repeat;
}
#logo
{
background-image: url(<?=$this->config->resource['img']?>/logo.gif);
}

Your HTML Template

Then in your template you add the link to the stylesheet. Personally i put it in the “_HeadTag.php” component.

<link rel="stylesheet" href="<?=$this->MakeLink('css', 'dynamic')?>" />

Tags: ,

Leave a Reply