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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Variables and inline CSS


Go to End


3 Posts   979 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, 6 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!