// you’re reading...

CMS

telerik RadEditor Snippets


Creating zillions of content classes in CMS for every type of imaginable widget an author may want seems like a fabulous idea at first, but it isn’t.  You make the CMS do much more work during publishing, and adding “pages” in CMS just to get a correctly formatted table in the body of your content is silly.  Snippets are the right answer and they’re supported right out-of-the-box with telerik.  They’re just off, so turn them on – this is how.

 

Step 1 – %CMSRoot/RadEditor.Net/Configuration/ToolsFile.xml

This file controls the global configuration of the RadEditor.  You will need to add a tool to one of the toolbars with the name InsertSnippet which (obviously) adds the drop-down list of snippets where you want it.  Then you add the snippets themselves by adding a new element, snippets, and putting the code you want for the snippet inside.  See below.

<root>
    <tools>
        <tool name="InsertSnippet" />
    </tools>
    <tools>
    ...
    </tools>
    <contextMenus>
    ...
    </contextMenus>
    <snippets>
        <snippet name="Standard Table">
            <![CDATA[
                <table summary="[Insert a table summary here for WCAG compliance]" class="nolines">
                    <thead>
                        <tr>
                            <th>Column 1</th>
                            <th>Column 2</th>
                         </tr>
                     </thead>
                     <tbody>
                         <tr>
                             <td>Digital Home</td>
                             <td>Consumer electronics</td>
                         </tr>
                     </tbody>
                </table>
            ]]>
        </snippet>
    </snippets>
</root>

Step 2 – Images

You can put icons in the snippet title, which is cool I reckon.

Just do this:

<snippet name="&lt;img src='images/Table.gif' /&gt; Standard Table">

Instead of this:

<snippet name="Standard Table">

The image doesn’t have to go at the front but it probably should.  Keep them small and remember the path is relative to the RadEditor.Net folder and not the CMS app itself. And be careful when mixing single and double quotes.  Lastly I have tried to use images from inside the Asset Manager for the icons but the URL seems to be too complicated.  Particularly in the escaping of &.  It can probably be done but I ran out of patience.

 

PS. Before you ask there is no easy way to do this on a placeholder-by-placeholder basis without multiple ToolsFile.xml files or some tricky hacked-in server-side code.  Go there at your own risk (it does work but it’s harder than described above).

Share and Enjoy:
  • Print
  • email
  • Twitter
  • Digg
  • Reddit
  • StumbleUpon
  • Google Bookmarks
  • del.icio.us
  • MisterWong
  • Facebook
  • LinkedIn

No related posts.

About the author:

Richard Hauer Richard is a Solution Architect with 5 Limes in Sydney, Australia. Richard has delivered CRM, .Net and RedDot solutions to many household name companies including Microsoft, Coca-Cola, Rothmans, Nestle, Tourism Australia, Network TEN, Australian Wool, Panasonic, the Royal Agricultural Society, Perpetual, and Challenger.

Discussion

No comments for “telerik RadEditor Snippets”

Post a comment



Stay up to date! - Get notified about followup comments

If you don't feel the urge to comment but wish to stay in the loop:
Just enter your email and subscribe to new comments.

Subscribe without commenting

Recent Tweets

  • RT @AirKraft: Transport Canada breakout: they manage 80K pages and 300K assets with WSM(RedDot). Wow! #OTCW 2010-11-11
  • The RedDot usergroup session 'Future of WCM' is in National Harbor 7, now. See you there! #otcw 2010-11-11
  • RT @yttergren: @AirKraft: Calling all WSM(RedDot) devs: share your solutions on http://bit.ly/bgPIof EVERY solution can win an iPad #OTCW 2010-11-10
  • Come to the Solution Exchange session. Enhance your (#reddot) CMS project! Chesapeake 12, 3:20pm #otcw Looking forward to see you there! 2010-11-10
  • More updates...