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, biapar, Willr, Ingo, swaiba, simon_w

Output of function not showing in widget


Reply


4 Posts   1121 Views

Avatar
oceanmountain

Community Member, 2 Posts

22 February 2013 at 1:34am

Hi!

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 Page.ss 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):
http://www.sspaste.com/paste/show/51260ea014393

The widget-template:
http://www.sspaste.com/paste/show/5126141bccdd4

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

Cheers!

Avatar
oceanmountain

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

Avatar
HARVS1789UK

Community Member, 21 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 :-)

Avatar
Nachos

Community Member, 21 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!