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.


Discuss SilverStripe Widgets.

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

Output of function not showing in widget


4 Posts   1031 Views


22 February 2013 at 1:34am Community Member, 2 Posts


I have a function inside a Widget that should return all the members of a given group. However, it seems to be impossible to loop through this function inside the widget. Once I put my function inside Page.php and loop through it in I get the expected results. Putting it back in the Widget and nothing happens. How to get the widget to show the output aswell?

The code I am currently using (function getMembers):

The widget-template:

I also tried $getMembers, but it was also useless. Any help is appreciated!



26 February 2013 at 10:04pm Community Member, 2 Posts

Thanks to g4b0 on the IRC the issue is resolved.
Putting the function getMembers() in a controller made it work :)


22 May 2013 at 8:22pm Community Member, 21 Posts

+1 for oceanmountain's solution!

This had been driving me crazy for ages as for some reason I was only seeing the issue (an empty widget which just showed the widget title and no content returned) when I had multiple widgets on the same page.

Even then if I had the widget at the top of the widget area (the first widget on the page) it would still work fine with the method in my model class rather than in my controller class :-S

Regardless as described above moving my method to the controller for all my widgets has solved the issue :-)


23 May 2013 at 12:38am (Last edited: 23 May 2013 11:19am), Community Member, 18 Posts

Hello HARVS1789UK and oceanmountain,

I'm having the exact problem that you describe. Could you please explain mit some more detail how to solve the issue with this controller method? Unfortunately I'm not savvy enough to imply the concrete steps. Would really appreciate it!
Thanks for your time!