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:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Accessing a controller method in template, when in control loop

Go to End

4 Posts   1902 Views


Community Member, 9 Posts

6 March 2012 at 11:06pm


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?


Community Member, 116 Posts

7 March 2012 at 8:18am

Hey MrNick,

Please post your function to and let me know what data you're trying to access from your function.



Forum Moderator, 5523 Posts

7 March 2012 at 7:23pm

You have to use $Top to call the topmost controller, $Top.MyControllerFunction.


Community Member, 9 Posts

8 March 2012 at 7:35am

Thanks Willr :) Excellent.