Jump to:

794 Posts in 409 Topics by 304 members


SilverStripe Forums » Widgets » Second widget with Control loop fails

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 709 Views
  • jebbench
    Community Member
    7 Posts

    Second widget with Control loop fails Link to this post

    Good afternoon,

    I've created two widgets, one that lists all pages of "HealthPage" type and provides a jump box and a second that lists all pages of "NewsPage" type.

    Both widgets work fine if they are the only widget on the page, as soon as I add the other widget the widget that renders second will fail.

    HealthPage Widget

    class HealthDropDownWidget extends Widget {

    public static $cmsTitle = 'Health Drop Down';
    public static $description = 'A clickable drop down menu for quick navigation to health pages.';

    public function HealthPageList() {
    return DataObject::get("HealthPage", "Status = 'Published'", "Title");


    HealthPage Template (trimmed)

    <select onchange="javascript:window.location.assign(this.value);">
    <option selected="selected" >Jump to section...</option>
    <% control HealthPageList %>
    <option value="$Link">$Title</option>
    <% end_control %>

    NewsPage Widget

    class NewsWidget extends Widget {

    public static $cmsTitle = 'News';
    public static $description = 'Displays the latest news stories.';

    public function NewsList() {
    return DataObject::get("NewsPage", "Status = 'Published'", "Date");


    NewsPage Template (trimmed)

    <% control NewsList %>
    <a href="$Link">Read more...</a>
    <% end_control %>

    I've tried the same code on a fresh database and I had the same issues.

    Any help is appreciated.

    James Bench

  • jebbench
    Community Member
    7 Posts

    Re: Second widget with Control loop fails Link to this post

    I've been having a play with this and I've discovered that it doesn't matter what's in the first widget the second widget will still fail, even if the first widget is just static HTML.

    While trying to debug this I have discovered that my 'NewsList' or 'HealthPageList' functions don't get called if they're the second widget.

    The widget still fail if they're the third or fourth widget.

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.