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

Is methodname($Pos) possible within a template control?


Go to End


2 Posts   1384 Views

Avatar
somerider

Community Member, 3 Posts

18 June 2010 at 7:04pm

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,

Avatar
Willr

Forum Moderator, 5523 Posts

18 June 2010 at 9:34pm

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.