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

After dragging a widget, its method is not executed anymore [solved]


Reply


457 Views

Avatar
rob.s

Community Member, 78 Posts

16 November 2011 at 6:11am

Edited: 16/11/2011 9:35pm

Hi,

i'm really confused about this really strange behaviour:
I'm working on a music band website with several widgets (for sidebar usage).

I have a custom pagetype that shows a collection of tour dates.
Everything works as expected.

Now there is a widget that shows up the next X dates inside a sidebar.
When this widget is dragged into the widget area and the page is saved - everything is still ok.
But when i drag the widget to a lower position (after an other widget) it does not work anymore.

In detail:
the widget has a method which is called from the widget template:

NextDatesWidget.php

class NextDatesWidget extends Widget {
...
function DateList()
{
Debug::dump('DateList called');
return DataObject::get('Tourdate', "DATE_FORMAT(Datum, '%Y%m%d') >= DATE_FORMAT(NOW(), '%Y%m%d')", 'Datum ASC', NULL, $this->NumberToShow);
}
...

NextDatesWidget.ss

<% if DateList %>
<table id="Next-Dates">
<% control DateList %>
<tr>
<td>$Datum.Format(d.m.Y)</td>
<td>$Ort</td>
</tr>
<% end_control %>
</table>
<% else %>
<div>-no dates found-</div>
<% end_if %>

After initial inserting the widget to the 1st position, the debug output shows up
After dragging the widget to an lower position, there is no debug output, even though the template is rendered.
And it shows the else condition "no dates found".

Very confusing ....
Any ideas ?

Greeting, Robert

Edit:
maybe a related thread?
[url]http://www.silverstripe.org/widgets-2/show/17518[/url]

Edit2:
Like posted in this thread: [url]http://www.silverstripe.org/widgets-2/show/16123[/url]

My /themes/mytheme/templates/WidgetHolder.ss file had the following content:

$Content

i had to wrap a "unique" named div around:

<div class="$ClassName">
$Content
</div>

Now it works ....