Jump to:

3392 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Appending .px to template variable

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

Page: 1
Go to End
Author Topic: 920 Views
  • Samba Sam
    Avatar
    Community Member
    85 Posts

    Appending .px to template variable Link to this post

    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

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Appending .px to template variable Link to this post

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

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

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Appending .px to template variable Link to this post

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

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

  • Samba Sam
    Avatar
    Community Member
    85 Posts

    Re: Appending .px to template variable Link to this post

    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

    920 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.