Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Is methodname($Pos) possible within a template control?

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

Page: 1
Go to End
Author Topic: 988 Views
  • somerider
    Avatar
    Community Member
    3 Posts

    Is methodname($Pos) possible within a template control? Link to this post

    Hi,
    I need to know if something like this is possible. I am trying to convert the position of an item in a control from a number to a letter of the alphabet.

    <% control FAQs %>   
    <div class="letter">$getnumberToLetter($Pos)</div>
    <h3>$Question</h3>
    $Answer
    <% end_control %>

    This currently throws me "Parse error: syntax error, unexpected T_STRING".

    The function works as expected when passing in an integer: $getnumberToLetter(2)

    Perhaps im on the wrong track entirely.

    Cheers,

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Is methodname($Pos) possible within a template control? Link to this post

    No you cannot pass variables into SS template tags (must be defined a constant). EG $Foo(Bar) will work but $Foo($Bar) won't. This is because the template parser only runs over the code once. So it will look for a function Foo and will pass a function Bar too it which is annoying but its one of the limitations of SSViewer. You'll have to find another way to do what you want.

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