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

SS3 Widget Module/WidgetAreaEditor Breaks CMS AJAX Functionality


Go to End
Reply


4 Posts   1669 Views

Avatar
HARVS1789UK

Community Member, 24 Posts

16 February 2013 at 12:02am

Edited: 16/02/2013 12:03am

I have a strange problem on the last two SS sites I have built (both are SS3.0.1 and above). I understand that the Widget Module is no longer packaged with a base SS install anymore so I have downloaded the Widget Module (https://github.com/silverstripe/silverstripe-widgets) and successfully installed it and created my own widgets etc.

I have given all my Pages the abillity to add Widgets and have this in my Page.php Class:


    public static $has_one = array(
        "MyWidgetArea" => "WidgetArea"
    );

    public function getCMSFields() {
        $fields = parent::getCMSFields();
        $fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("MyWidgetArea"));
        return $fields;
    }

The widget area itself works fine and I have no issues with it (with the exception of known bugs when using checkboxes etc) however, when I try to navigate to (or around the tabs within) a page in the CMS that uses the widget area the AJAX loading of that page fails. For example from the SiteTree page list I go to my 'Contact Us' page (which has a WidgetAreaEditor on it) the blue loading bar/overlay appears, ticks away, my URL gets updates and the overlay/loader disappear....but my page location is the same, the appropriate page content has not been loaded in.

Looking at the Network tab in Google Chrome I can see the correct request is being made and data returned with HTTP 200 OK message (see below screenshot), but then nothing happens.

I am certain it is related to Widgets as on all other CMS pages (e.g. Settings, Security etc) the AJAX loading works fine and on any pages where I remove the WidgetAreaEditor functionality it then loads the page correctly e.g. on a page where I want no Widgets configurable I have:

    public function getCMSfields() {
        $fields = parent::getCMSFields();
        $fields->removeByName("Content");
        $fields->removeFieldFromTab('Root', 'Widgets');
        return $fields;
    }

This is driving me crazy and obviously I can't hand the site over to the client and say "to use the CMS click on the appropriate page, then do a page reload because its broken!" :-(

Any help would be much appreciated!

Cheers,

HARVS1789UK

Avatar
HARVS1789UK

Community Member, 24 Posts

2 March 2013 at 3:26am

Edited: 02/03/2013 3:27am

Bump!

Does no body have any ideas :-(

Perhaps more importantly is anyone else actually having this problem?

Avatar
leigh

Community Member, 3 Posts

10 January 2015 at 11:26am

I'm having an identical issue after creating a new Admin page. I'm fairly sure it's something I've implemented incorrectly, but as yet I haven't diagnosed the cause. All the pages including the new one load fine after a refresh.

When I track down the cause I'll post the details.

Avatar
leigh

Community Member, 3 Posts

12 January 2015 at 4:57pm

I've diagnosed and resolved the cause of this issue. It's mandatory that all files have a new line at the end. I don't know whether the culprit in my case was one of the PHP files or a .yaml or a _config ... but I made sure all the files ended with a new line and the bug disappeared (I do regard it as a bug - so far as I've been able to discover, the new line isn't a documented requirement).