How to add a widget with in content block with WYSWYG editor

Posted by Community Admin on 04-Aug-2018 09:00

How to add a widget with in content block with WYSWYG editor

All Replies

Posted by Community Admin on 09-Aug-2013 00:00

Hello All,

I have a requiremnt in my project where I can add a custom widget through WYSWYG editor in content block. Basically I want a way where I can customize editor toolbar to add one more button on toolbar and on click of that I can fire an event to open the widget and after doing settings when clicking on save I'll have that widget in html content. So after adding content block on page, I can click on edit and on editor's toolbar of editor, I can have a button to click to get widget on html content.

Would like to get it more clear.

The WYSISYG editor is part of the Content block widget (http://d.pr/i/edZL )
which we drop on page. We don’t have direct access to the RadEditor where I can
make change and fire some code behind event. I have put the button in
‘StandardToolsFile.xml’ xml as below and done the settings Sitefinity
backend >> Administration
>> Settings >> Advanced >> Appearance but not sure where to write the custom code to handle
click event of a button.

 <tools name="MainToolbar" dockable="true" enabled="true"> 
 <tool name="Add Gallery" /> 
</tools>

Any help would be much appreciated.

Thanks
Sanjay

Posted by Community Admin on 09-Aug-2013 00:00

Why overcomplicate this?

Why can't the user just do
<content block>
<widget>
<content block>

I don't understand the need to do this...
<content block>
    <widget>
</content block>

What is this widget you're talking about, certainly not like any default sitefinity widget...?

...incidentally you do have direct radeditor access if you map that control template out to an external view...however doing so can introduce multiple problems going forward if telerik changes the template or adds things.  I mean if you're AWARE of that you can adjust when it happens...

Posted by Community Admin on 09-Aug-2013 00:00

there are definitely good valid use-cases for wanting to include sitefinity content inside a content block. By doing the
<contentblock />
<widget />
<contentblock />

you lose the ability to wrap the content a) inside a container div and b) inside the container content div.

 The way I have solved this in the past is by adding support for Shortcodes to be injected into the content html. Here's an introduction: http://www.sitefinity.com/blogs/josh-morales-blog/2012/12/04/supporting-shortcodes-in-sitefinity-content

And here's an example of how you can display a link to a blog post inside a content block, even using the RadToolBar to select one to show: http://www.sitefinity.com/blogs/josh-morales-blog/2012/12/10/creating-shortcodes-for-sitefinity-blog-posts

You could use this technique to embed the blog post summary, or title, or really anything, as well as show an image or document from the library. You simply need to change how the template codebehind parses and replaces the shortcode.

I hope this is helpful!

This thread is closed