Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Adding variables to CSS

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

Page: 1
Go to End
Author Topic: 557 Views
  • Puppy
    Avatar
    Community Member
    10 Posts

    Adding variables to CSS Link to this post

    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)

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Adding variables to CSS Link to this post

    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");
    }

    557 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.