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'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.

Template Questions /

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

Parsing a CSS/PHP file - possible?


Go to End


2 Posts   1845 Views

Avatar
prezet

Community Member, 6 Posts

22 April 2014 at 6:45am

I'd like to parse a single CSS file in the context of the page I'm viewing, so I can set background images to the url's of files that the client has uploaded. Would something like this be possible within Silverstripe?

.hero {
  background-image: url('{$HeroImage.URL}') no-repeat;
}

Avatar
camfindlay

Forum Moderator, 267 Posts

22 April 2014 at 9:49am

You can use customCSS requirements in your Page_Contoller init() method. See http://doc.silverstripe.org/framework/en/reference/requirements#custom-inline-scripts