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

HTML widget in 2.3.0


Go to End


20 Posts   12708 Views

Avatar
sysyphus

Community Member, 20 Posts

22 May 2009 at 11:41am

Edited: 22/05/2009 12:35pm

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

Community Member, 57 Posts

24 May 2009 at 12:31am

It should be a TextareaField not a TextAreaField. Sorry.

Avatar
FungshuiElephant

Community Member, 57 Posts

26 May 2009 at 2:03am

Edited: 26/05/2009 2:38am

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.

Avatar
sysyphus

Community Member, 20 Posts

26 May 2009 at 10:17pm

Edited: 26/05/2009 10:19pm

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

Community Member, 49 Posts

21 June 2009 at 5:54pm

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

Community Member, 57 Posts

2 July 2009 at 1:55am

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

Community Member, 3 Posts

18 August 2009 at 4:32am

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

126 Posts

30 November 2009 at 3:43pm

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