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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Widgets /

Discuss SilverStripe Widgets.

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

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


Go to End


1627 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?
http://www.silverstripe.org/widgets-2/show/17518

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

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 ....