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.

General Questions /

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

Variables and inline CSS


Reply


3 Posts   560 Views

Avatar
MagicUK

Community Member, 60 Posts

13 July 2011 at 2:24am

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?

Avatar
Christopher Darling

Community Member, 5 Posts

13 July 2011 at 2:30am

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

Avatar
MagicUK

Community Member, 60 Posts

13 July 2011 at 2:40am

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