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

Second widget with Control loop fails

Go to End

2 Posts   1286 Views


Community Member, 7 Posts

17 July 2011 at 2:24am

Edited: 17/07/2011 2:25am

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


Community Member, 7 Posts

18 July 2011 at 1:00am

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.