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.

Template Questions /

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

Appending .px to template variable


Go to End


4 Posts   1687 Views

Avatar
Samba Sam

Community Member, 85 Posts

20 February 2010 at 1:38pm

Hi,
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">

returns
<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,
Sam

Avatar
Willr

Forum Moderator, 5523 Posts

20 February 2010 at 2:03pm

Edited: 22/02/2010 6:12pm

You need to escape the variable like {$Var}px

Edit - Woops, had a dot after the }. Thanks banal

Avatar
bummzack

Community Member, 904 Posts

20 February 2010 at 8:22pm

Yes, what Will said, but skip the dot ;)
Like this:

"margin: {$TopMargin}px 0 0 {$LeftMargin}px;"

Avatar
Samba Sam

Community Member, 85 Posts

20 February 2010 at 8:42pm

Thanks Guys. It works!

For some strange reason I added an unnecessary period in front of the px in my original post.
Don't need it.

Cheers,
Sam