am I missing something here....doesn't the customCSS requirement just stick it in the <head> section of the page anyway??
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
- Previous 10 entries
- 1
- Page 22(current)
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).
Because the <% require %> feature isn't allowing me to reference a variable inside it?
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.
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)
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
- Previous 10 entries
- 1
- Page 22(current)