Jump to:

23483 Posts in 18976 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Variables and inline CSS

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 519 Views
  • MagicUK
    Avatar
    Community Member
    60 Posts

    Variables and inline CSS Link to this post

    Hello. This might be a stupid one, but, well, I'm stupid.

    I have the following code in one of my template files:

    <div id="EventTitleHeader" style="font-size:30px">
       $eventtitle
    </div>

    I want to make the title of the site controllable in the CMS (variable $eventtitleSize) so I added the following code:

    <div id="EventTitleHeader" style="font-size:$eventtitleSizepx">
       $eventtitle
    </div>

    As you can guess this doesn't work cause the variable is now part of the 'px' value. Unfortunately adding a space will result in the CSS not working either. Is there a workaround for this?

  • Christopher Darling
    Avatar
    Community Member
    5 Posts

    Re: Variables and inline CSS Link to this post

    Put braces around the variable e.g. style="font-size:{$eventtitleSize}px"

  • MagicUK
    Avatar
    Community Member
    60 Posts

    Re: Variables and inline CSS Link to this post

    Thank you!! I knew it would be something like that!

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