Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » Pass Param to Function from Template

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

Page: 1
Go to End
Author Topic: 1553 Views
  • spankmaster79
    Avatar
    Community Member
    46 Posts

    Pass Param to Function from Template Link to this post

    Hi,

    I need to pass a param from within the template back to a function, but as it seems this is not possible.

    <% control Items %>
    $Top.CheckSomething($Property) %>
    <% end_control %>

    If I only pass "Property" and return the value, the String Property is echoed. Using $Property I get a Parse error: syntax error, unexpected T_STRING, expecting ')

    I had it a couple of times now that I needed to pass something back to the controller.

    A good example might be that I get a DataObjectset from the database and iterate through them. Then I need to check a value from one item against the values of all retuned items. The Item itself doesn't know it's siblings so I need to do this in the Controller. But the controller can't access the iterator of the DataobjectSet or at least I don't know how to.

    Urgently need help.......

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Pass Param to Function from Template Link to this post

    This comes up very often and the answer is you cannot do it...

    http://doc.silverstripe.org/sapphire/en/reference/templates#variables

    What you can do is write something in teh controller to handle it

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