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

HTML widget in 2.3.0


Reply

20 Posts   7371 Views

Avatar
sysyphus

22 May 2009 at 11:41am (Last edited: 22 May 2009 12:35pm), Community Member, 20 Posts

Hi I tried the fix you suggested in your last post FungshuiElephant, now when I move the widget over I get:

Fatal error: Class 'TextAreaField' not found in /home/kidscost/public_html/widgetHtmlContentWidget/HtmlContentWidget.php on line 24

Any thoughts?

Avatar
FungshuiElephant

24 May 2009 at 12:31am Community Member, 57 Posts

It should be a TextareaField not a TextAreaField. Sorry.

Avatar
FungshuiElephant

26 May 2009 at 2:03am (Last edited: 26 May 2009 2:38am), Community Member, 57 Posts

I have a feeling that [url=http://www.silverstripe.org/widgets-2/show/258893?start=0#post261255]this fix for checkboxes[/url] may also fix the problem with HTMLEditor fields not saving or saving with the content label included. Seemed to work with 2.3.1.
<br >
<br >It won't make the Tiny MCE editor appear as soon as the widget is added that requires a bit of javascript to assign the behaviour - just save and refresh the page to get that.
<br >
<br >You can change tinymce.template.js and/orWidgetAreaEditor.css if you don't like the editor toolbars sticking out of the side of the box. Or better still, override in you own files rather than in core.
<br >
<br >If you try it, please report back.

Avatar
sysyphus

26 May 2009 at 10:17pm (Last edited: 26 May 2009 10:19pm), Community Member, 20 Posts

Thanks, I should have worked out The TextareaField .....

It's now not breaking I'll try the fix you suggested in your next post to see if I can get the widget to show on my page

Avatar
Web Designer Perth

21 June 2009 at 5:54pm Community Member, 49 Posts

I had it working in 2.3.1 but needed to edit my content. Now I can't save and I can't even remove the widget altogether (clicking the red x). I have all kinds of jibberish appearing now. I'm very new to SS - is there another way to remove the widget?

Thx in advance.

Avatar
FungshuiElephant

2 July 2009 at 1:55am Community Member, 57 Posts

You can delete a Widget from a WidgetArea by deleting the corresponding row from the Widgets table in the database. Just look through the table until you find the row with the right widget name. They're grouped by ParentID; the widgets from a given widgetarea all have the ParentID.

Be sure that you delete the right one!

Avatar
AlexR

18 August 2009 at 4:32am Community Member, 3 Posts

I have just spent some time playing about trying to get this widget to save with the HTML editor.

The problem stems from the fact that the HtmlEditor field assumes that it will always be in the page. To get around this I had to amend the js source code slightly.

I amended the file: [site_root]\jsparty\tiny_mce2\tiny_mce_src.js.

Search for "save : function(o)" (~ line 7730)

All you want to do is add a check to determine if the element exists or not.

Replace the following code:

if (!/TEXTAREA|INPUT/i.test(e.nodeName)) {
   e.innerHTML = h;
   
   // Update hidden form element
   if (f = DOM.getParent(t.id, 'form')) {
      each(f.elements, function(e) {
         if (e.name == t.id) {
            e.value = h;
            return false;
         }
      });
   }
} else
   e.value = h;

with this code:

if( e )
{
   if (!/TEXTAREA|INPUT/i.test(e.nodeName)) {
      e.innerHTML = h;
   
      // Update hidden form element
      if (f = DOM.getParent(t.id, 'form')) {
         each(f.elements, function(e) {
            if (e.name == t.id) {
               e.value = h;
               return false;
            }
         });
      }
   } else
      e.value = h;
}

Avatar
Anatol

30 November 2009 at 3:43pm 126 Posts

Hi AlexR,

thanks for that fix. Wrapping the "if( e ) {" ... "}" code around works well. I initially wrote the widget but didn't have the time to fix the problem. But as it seems it just doesn't work any more since Silverstripe has the editor bar in the text field itself (which is a good choice except for widgets). If anyone knows a way to fix the problem in the widget code only without changing the core code please post it here. I still think it would be a simple yet useful widget.

Cheers!
Anatol