Jump to:

3439 Posts in 1028 Topics by 869 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: 1011 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

  • baba-papa
    Avatar
    Community Member
    279 Posts

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

    <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.

  • lerni
    Avatar
    Community Member
    80 Posts

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

    hi

    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?

    luk

  • baba-papa
    Avatar
    Community Member
    279 Posts

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

    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.

    1011 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.