753 Posts in 310 Topics by 289 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 514 Views |
-
Second widget with Control loop fails

17 July 2011 at 2:24am Last edited: 17 July 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 %>
</select>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 %>
<div>
<span>$date.Nice</span>
$Content
<a href="$Link">Read more...</a>
</div>
<% end_control %>I've tried the same code on a fresh database and I had the same issues.
Any help is appreciated.
Cheers,
James Bench -
Re: Second widget with Control loop fails

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.
| 514 Views | ||
|
Page:
1
|
Go to Top |

