More in this section

Forums / Developing with Sitefinity / How to add a widget with in content block with WYSWYG editor

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

3 posts, 0 answered
  1. Sanjay
    Sanjay avatar
    3 posts
    09 May 2013
    09 Aug 2013
    Link to this post
    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 ( )
    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" /> 

    Any help would be much appreciated.


  2. Steve
    Steve avatar
    3037 posts
    03 Dec 2008
    09 Aug 2013 in reply to Sanjay
    Link to this post
    Why overcomplicate this?

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

    I don't understand the need to do this...
    <content block>
    </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...
  3. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    18 Jul 2012
    09 Aug 2013 in reply to Steve
    Link to this post
    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:

    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:

    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!
3 posts, 0 answered