Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

<% require %> custom CSS


Go to End


14 Posts   5562 Views

Avatar
Carbon Crayon

Community Member, 598 Posts

23 April 2009 at 11:51am

am I missing something here....doesn't the customCSS requirement just stick it in the <head> section of the page anyway??

Avatar
Hamish

Community Member, 712 Posts

23 April 2009 at 3:19pm

Yeah, I'm not sure what the problem is. Requirements will always put them in the right place.

Adding requirements from the template is a relatively new feature. You could add a feature request for more power in the customCSS method, at http://open.silverstripe.com, or just do the old way (adding it to your page class).

Avatar
chrisdarl

Community Member, 33 Posts

23 April 2009 at 7:39pm

Because the <% require %> feature isn't allowing me to reference a variable inside it?

Avatar
Carbon Crayon

Community Member, 598 Posts

23 April 2009 at 10:16pm

function init() {

parent::init();

Requirements::customCSS( "background : url(" . $this->LeftBlock2_Image()->URL . ");");

}

Thats off the top of my head so the syntax may be slightly different but you get the idea.

Avatar
chrisdarl

Community Member, 33 Posts

24 April 2009 at 10:31am

Thanks Aram for all your help - it's really appreciated!

I'll give that a go and post the code I succeed with (well hopefully)

Avatar
chrisdarl

Community Member, 33 Posts

27 April 2009 at 6:12am

I got this working by using Arams suggestion. I put the following code inside the init function of my Page_Controller

if($this->TopImage()->ID) {
Requirements::customCSS(".top-image { background : url(".$this->TopImage()->URL.") no-repeat !important; height : ".$this->TopImage()->getHeight()."px !important; }");
}

Thanks for helping Aram and Hamish

Go to Top