Is there a way to create a dynamic stylesheet that is built from setting some values in the CMS?
For example I have a DataObject 'Theme Settings' with the following $db array:
<?php class ThemeSettings extends DataObject {
private static $db = array(
'H1Color' => 'Text',
'H2Color' => 'Text',
'H3Color' => 'Text',
'H4Color' => 'Text',
'H5Color' => 'Text',
'H6Color' => 'Text',
'TextColor' => 'Text',
'LinkColor' => 'Text',
'LinkHoverColor' => 'Text',
'BackgroundColor' => 'Text',
'HeaderColor' => 'Text',
'NavBgColor' => 'Text',
'NavBgHoverColor' => 'Text',
'NavTextColor' => 'Text',
'NavTextHoverColor' => 'Text',
'HeaderText' => 'Text'
);
}
At the moment I am just outputting the data in the head of the document through the init function:
public function init() {
parent::init();
$settings = $this->FetchSettings();
if($settings){
Requirements::customCSS(
//css goes in here
);
}
}
But I would prefer to be able to generate an actual custom.css file and attach it (so I don't have to add the css with every page load). Has anyone got any ideas how to implement this?