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.

Widgets /

Discuss SilverStripe Widgets.

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

Output of function not showing in widget

Go to End

4 Posts   1953 Views


Community Member, 2 Posts

22 February 2013 at 1:34am


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!



Community Member, 2 Posts

26 February 2013 at 10:04pm

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


Community Member, 31 Posts

22 May 2013 at 8:22pm

+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 :-)


Community Member, 22 Posts

23 May 2013 at 12:38am

Edited: 23/05/2013 11:19am

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!