Hi
I have added a dropdown to my CMS to allow the administrator to choose the background colour of a page.
class Page extends SiteTree {
public static $db = array(
'BgColour' => 'varchar'
);
public static $has_one = array(
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new DropdownField('Background', 'Background Colour',singleton('PageColourScheme')->dbObject('BgColour')->enumValues()
), 'Content');
return $fields;
}
}
class PageColourScheme extends DataObject {
static $db = array(
"BgColour" => "Enum('Pink, Purple, Green, Yellow','Pink')"
);
};
This all seems to work fine but the script that detects the colour selected and then applies the right css file to the page
<% if BgColour=Pink %>
<% require themedCSS(pink_layout) %>
<% else %>
<% require themedCSS(green_layout) %>
<% end_if %>
fails in that both lines are returned in the template i.e. I get
<link rel="stylesheet" type="text/css" href="http://www.lowdown.org.nz/themes/lowdown/css/pink_layout.css?m=1241341643" />
<link rel="stylesheet" type="text/css" href="http://www.lowdown.org.nz/themes/lowdown/css/green_layout.css?m=1241344957" />
I have a similar version of this script running so that the administrator can chose the header which is applied so I am guessing that this issue has something to do with it being in the <head> section of the script. Can I do this? If so where am I going wrong?
Thanks
MM