5101 Posts in 1519 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 349 Views |
-
Adding variables to CSS

21 June 2011 at 3:26am
Hey guys,
I'm at a stumbling point in my knowledge of Silverstripe and was wondering if I could ask for your suggestions.
My issue is I would like to have a user-selected background image, which is applied in the CSS, from whichever picture is selected or uploaded by an uploadify imageuploadfield.
I've done a similar slideshow, where the image is applied using the inline style attribute, although it would be ideal to have the background image path printed out to an external CSS file for each different page (probably using a page ID on the body element).
If you have tried something like this before and think you could help direct me to the most efficient method, please do!
Thanks for your responses in advance,
Jimi
(aka Justify)
-
Re: Adding variables to CSS

22 June 2011 at 1:38am
Hi,
I would do this within PHP (as it's easiest to access the File/Image) and then place it into the CSS in Page init using...
public function init() {
parent::init();
//get the image name into $strImage
Requirements::customCSS("<<DO CSS STUFF HERE WITH>> $strImage");
}
| 349 Views | ||
|
Page:
1
|
Go to Top |


