Jump to:

791 Posts in 369 Topics by 303 members

Widgets

SilverStripe Forums » Widgets » Output of function not showing in widget

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 767 Views
  • oceanmountain
    Avatar
    Community Member
    2 Posts

    Output of function not showing in widget Link to this post

    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!

  • oceanmountain
    Avatar
    Community Member
    2 Posts

    Re: Output of function not showing in widget Link to this post

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

  • HARVS1789UK
    Avatar
    Community Member
    14 Posts

    Re: Output of function not showing in widget Link to this post

    +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

  • Nachos
    Avatar
    Community Member
    17 Posts

    Re: Output of function not showing in widget Link to this post

    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!

    767 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.