Jump to:

794 Posts in 409 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » HTML widget in 2.3.0

Discuss SilverStripe Widgets.

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

Page: 1 2 3
Go to End
Author Topic: 7318 Views
  • sysyphus
    Avatar
    Community Member
    20 Posts

    Re: HTML widget in 2.3.0 Link to this post

    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?

  • FungshuiElephant
    Avatar
    Community Member
    57 Posts

    Re: HTML widget in 2.3.0 Link to this post

    It should be a TextareaField not a TextAreaField. Sorry.

  • FungshuiElephant
    Avatar
    Community Member
    57 Posts

    Re: HTML widget in 2.3.0 Link to this post

    I have a feeling that this fix for checkboxes 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.

  • sysyphus
    Avatar
    Community Member
    20 Posts

    Re: HTML widget in 2.3.0 Link to this post

    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

  • Web Designer Perth
    Avatar
    Community Member
    49 Posts

    Re: HTML widget in 2.3.0 Link to this post

    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.

  • FungshuiElephant
    Avatar
    Community Member
    57 Posts

    Re: HTML widget in 2.3.0 Link to this post

    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!

  • AlexR
    Avatar
    Community Member
    3 Posts

    Re: HTML widget in 2.3.0 Link to this post

    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;
    }

  • Anatol
    Avatar
    126 Posts

    Re: HTML widget in 2.3.0 Link to this post

    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

    7318 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.