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:

Template Questions /

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

Appending .px to template variable

Go to End

4 Posts   1261 Views

Samba Sam

Community Member, 85 Posts

20 February 2010 at 1:38pm

How would I append to .px to a template variable.

For example,

This in the template
<div id="FlashContainer" style="margin:$TopMargin.px 0 0 $LeftMargin.px">

<div id="FlashContainer" style="margin: 0 0 ">

How do I add .px to the end of $TopMargin or $LeftMargin so that I get something like:
<div id="FlashContainer" style="margin:300.px 0 0 400.px">

Thanks in advance,


Community Member, 279 Posts

7 March 2010 at 5:12am

Edited: 07/03/2010 5:13am

<div id="FlashContainer" style="margin:{$TopMargin}px 0 0 {$LeftMargin}px">

Don´t let anyone change CSS via the backend, this will blow up in your face sooner or later.


Community Member, 81 Posts

7 March 2010 at 7:02am


i guess the issue is solved with {$x}px.

but baba-papa ok there are pros & contras for controlling styles trough the cms - what is best practice if you do? would you make inline styles in the template? how do you actually use $vars in the css files?



Community Member, 279 Posts

7 March 2010 at 8:19pm

Usualy customers are the ones that work with the backend. As they do not know much about css or browser bugs they should not interact with css.