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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   1335 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!