21295 Posts in 5734 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » Accessing a controller method in template, when in control loop
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 178 Views |
-
Accessing a controller method in template, when in control loop

6 March 2012 at 11:06pm
Hello,
In my controller I have a function which I want to call in my template.
This works fine, however when I am in a control loop eg,
<% control articles %>
<p>$Name</p>
$MyControllerFunction
<% end_control %>It outputs $Name fine, but fails on $MyControllerFunction as it seems to be trying to access a method/property on the article.
How can I get the controller function?
-
Re: Accessing a controller method in template, when in control loop

7 March 2012 at 8:18am
Hey MrNick,
Please post your function to http://www.pastie.org and let me know what data you're trying to access from your function.
Cheers,
Josh -
Re: Accessing a controller method in template, when in control loop

7 March 2012 at 7:23pm
You have to use $Top to call the topmost controller, $Top.MyControllerFunction.
-
Re: Accessing a controller method in template, when in control loop

8 March 2012 at 7:35am
Thanks Willr
Excellent.
| 178 Views | ||
|
Page:
1
|
Go to Top |



