Widgets, widgets, widgets

132 views
Skip to first unread message

Artyom

unread,
Dec 20, 2010, 7:39:49 PM12/20/10
to SilverStripe Core Development
Hi all. I wanted to discuss the status of the Widgets infrastructure
generally. Recently I've turned with some hope and initial
excitement in the direction of using widgets more and more (mostly my
own and mods of others). I think the concept is quite powerful and
flexible, and users really like it.

However, I have run into some significant but hopefully solvable
issues. Namely there are some bugs in how widgets' CMS fields are
persisted at the FormField level, which precludes alot of ordinary
uses.

I wanted to ask the core team what the plan and thinking is around
widgets generally. Is there going to be (or is there already in
process) a plan for a reworking / enhancement of the widget
infrastructure? In the mean time, can we fix some of these duplicate
ID bugs (which have been open for like 2 years).

I for one really find the idea of allowing clients the flexibility of
putting whatever they want in their sidebars very powerful and
useful. It also is one of those things that allows SilverStripe to
stack up well with other CMS solutions like concrete5, joomla,
wordpress etc.

thoughts?

Nicolaas Thiemen Francken - Sunny Side Up

unread,
Dec 20, 2010, 7:43:47 PM12/20/10
to silverst...@googlegroups.com
I second that wholeheartedly.

Will Rossiter

unread,
Dec 20, 2010, 7:43:49 PM12/20/10
to silverst...@googlegroups.com
 In the mean time, can we fix some of these duplicate
ID bugs (which have been open for like 2 years).

Patches welcome :)

--
Will Rossiter | Developer
SilverStripe
http://www.silverstripe.com

Mobile: +64 27 389 3454
Office: +64 4 978 7330 ext 58
Skype: will.rossi

Level 5, 97-99 Courtenay Place
Wellington, New Zealand




Artyom

unread,
Dec 20, 2010, 8:04:43 PM12/20/10
to silverst...@googlegroups.com
Well, I'm happy to look into it more and contact some others that have
tried to fix, but I wanted to check first so I'm not duplicating
effort or doing somthing that twill be rendered useless but core
changes or something like that. : - )

> --
> You received this message because you are subscribed to the Google Groups
> "SilverStripe Core Development" group.
> To post to this group, send email to silverst...@googlegroups.com.
> To unsubscribe from this group, send email to
> silverstripe-d...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/silverstripe-dev?hl=en.
>

Artyom

unread,
Dec 23, 2010, 2:04:00 AM12/23/10
to silverst...@googlegroups.com, Silverstripe
FYI.. I just submitted a patch to 6288 which contains the suggested
fix that FungshuiElephant had tried some time ago. It does in fact
fix the HTML editor issue --which I consider a major step forward for
widgets and widget use.

one caveat: You have to *save* the page in the beginning, and also
*every time you move* the widget using the drag capability. (This is
presumably due to js DOM confusion which relies on positioning...)

thanks FungshuiElephant : - )

best,
Artyom

Martijn Van Nieuwenhoven

unread,
Dec 24, 2010, 4:20:07 AM12/24/10
to silverst...@googlegroups.com
Hi All,

I did some rewriting of the WidgetEditorArea as well to make the HTMLEditorField work for widgets.

I rewrote the javascript in WidgetEditorArea.js to jQuery (sortable) and made some additional changes to the templates of the widget editor.

The main thing to make the HTMEditorField work is to change the field ID's to names with underscores instead of brackets and use tinymce buildin methods to bind/unbind after DOM change:

// jQuery.sortable start:
if (typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById($(this).attr('id'))){
    tinyMCE.execCommand('mceFocus', false, $(this).attr('id'));
    tinyMCE.execCommand("mceRemoveControl", false, $(this).attr('id'));
}
//jQuery.sortable stop:
if (typeof tinyMCE != 'undefined'){
    tinyMCE.execCommand("mceAddControl", false, $(this).attr('id'));
    tinyMCE.triggerSave();
}

Like I sead, I had no time to port it to a Silverstripe patch, so you still need to block the core WidgetEditorArea.js in Page::getCMSFields();

function getCMSFields() {
        $fields = parent::getCMSFields();       
       
        $fields->addFieldToTab("Root.Content.Widgets", new WidgetAreaEditor("WidgetsRight"));
        Requirements::block('cms/javascript/WidgetAreaEditor.js');
        Requirements::javascript('widgeteditor/javascript/WidgetAreaEditor.js');
        return $fields;
    }

Please test the attached files and if your ok with it i'm happy to port it to SS patches later on.
The zip contains the rewritted widget_editor and a ContentEditor with a HTMLEditorField.

Cheers,
Martijn
widgeteditor.zip

Artyom

unread,
Dec 24, 2010, 12:14:11 PM12/24/10
to silverst...@googlegroups.com
Thanks Martijn. I'll have a look when I have time.

Artyom

unread,
Dec 24, 2010, 12:17:51 PM12/24/10
to silverst...@googlegroups.com
Martijn, what does the js do functionally that was broken before?

thanks,
A

Martijn Van Nieuwenhoven

unread,
Dec 25, 2010, 6:01:27 AM12/25/10
to silverst...@googlegroups.com
it makes the tinymce editor work with sorting and adding widgets :).

Dan Rye

unread,
Dec 25, 2010, 2:34:35 PM12/25/10
to silverst...@googlegroups.com
It'd be nice to start supporting image uploads from widgets as well.

Sent from my iPhone

Artyom

unread,
Dec 25, 2010, 4:06:47 PM12/25/10
to silverst...@googlegroups.com
Oh I see. Ok, currently the workaround is saving the page whenever
you move or add one. And this fixes that. Is that correct?

On Sat, Dec 25, 2010 at 3:01 AM, Martijn Van Nieuwenhoven

Martijn Van Nieuwenhoven

unread,
Dec 26, 2010, 6:05:56 AM12/26/10
to silverst...@googlegroups.com
Yes, it removed the tinymce from DOM when sort starts and readds it to the DOM when sortable is finished.

Artyom

unread,
Dec 26, 2010, 6:16:42 AM12/26/10
to silverst...@googlegroups.com
Great. Thanks. By "sort" you mean after the user drags it to a
different slot in the order?

On Sun, Dec 26, 2010 at 3:05 AM, Martijn Van Nieuwenhoven

Dan Rye

unread,
Dec 27, 2010, 11:21:35 PM12/27/10
to silverst...@googlegroups.com
Another issue with widgets, they don't respect canCreate.  I discovered this while trying to limit a widgetarea to only allowing one of a certain widget.
Reply all
Reply to author
Forward
0 new messages