News Articles

Optimizing the FCKEditor for DNN

The FCKEditor in DNN allows for rich text editing, and as a WYSIWYG tool, it does a great job. A recurring goal for many of my DotNetNuke customers is to distribute content administrative rights to a broad audience. This is a realistic goal, and the FCKEditor helps to provide content administrators the tools to create and edit content without detailed knowledge of HTML.

fg5 - Toolbar

Here’s my beef… The default toolbar set for the FCKEditor in DNN really give the content editors a lot of ways to kill the elegance of a well thought-out design. The top offenders are (in no particular order):

  • Style list fg5.7-style
  • Insert Smiley fg5.6-smiley
  • Font Colorfg5.7-fontcolor
  • Font fg5.7-font
  • Background Color fg5.7-bgcolor

There are some configuration options available to anyone with file system access that I would recommend to any implementation of DNN. (Quick note: if you have multiple portals within an instance of DNN the changes you make will affect all portals.)

Clean Up the Toolbar

The default DNN toolbar gives the basic content administrator too many options. Most of the functions in the toolbar shouldn’t be used and clutter the users experience. In my opinion, we should only provide users the tools we want them to use. Personally, I hate the idea of someone applying inline styles or non-semantic markup to the site. Its too hard to account for (dummy proof) in the style sheets.

Solution: create a streamlined toolbar by modifying the fckconfig.xml file. Technically, you should create a custom toolbar and then apply permissions to this new toolbar. I don’t find any real benefit to doing it the “correct way.” In most cases I don’t provide a different set of tools to different users. Is is possible? Yes, but for most of the cases one toolbar is suffice. So I typically just modify the DNNDefault toolbarset.

How: Locate the fckconfig.js file in the website files for DNN. This file is located at [root]\Providers\HtmlEditorProviders\Fck\Custom. Within this file, there is a section that defines the functions available in the Toolbars (search for Toolbarsets). It looks a little something like this:

FCKConfig.ToolbarSets["DNNDefault"] = [
	['Source','Preview','-','Templates'],
	['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
	['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
	['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
	['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],
	['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
	['Link','Unlink','Anchor'],
	['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
	['Style','FontFormat'],['FontName','FontSize'],
	['TextColor','BGColor'],
	['FitWindow','ShowBlocks','-','About']
] ;

You can easily see that the items listed in the Toolbar are easily mapped to features of the FCKEditor. By trimming this down to only the bare essentials and maybe even rearranging the features to be more intuitive, the FCKEditor can make content administration a breeze for your editors and you as the administrator can sleep easy at night knowing Smileys won't be showing up on your content.

To see my prefered toolbar in action download my preferred version of the DNNDefault toolbar (a txt file to allow you to paste into your fckconfig.js).

Use Only the Style List and Clean it Up

From a training standpoint the Style and Format lists are hard to differentiate. To a basic content administrator it is a list of ways to change the text. In reality the Format list applies different semantic markup options to the text and the Style list applies a mix of markup tags and inline styles. If you’re like me, giving users the ability to apply inline styles really gets your goat.

Solution: give the end user only one list to pick from and be very prescriptive about the options available to pick. To do this, you’ll want to clean up the list of styles offered by the FCK Editor

How: There are two steps to cleaning up the styles list. First, we need to get rid of “Red Title.” Why would anyone use this? Gross. To get rid of “Red Title” we need to delete a few lines of code from the file we were already editing for the toolbar (fckconfig.js)

FCKConfig.CustomStyles =
{
	'Red Title'	: { Element : 'h3', Styles : { 'color' : 'Red' } }
};

Just kill this code completely. Next, we’ll create a list of styles we do want to include for users to apply different styles to the content. Since we removed the Format list from the toolbar, we can incorporate the standard headings and any other semantic markup into the list of styles and remove the elements that produce inline styles. To edit the styles list, locate the file titled fckstyles.xml. This file is located here: [root]\Providers\HtmlEditorProviders\Fck\FCKeditor.

My approach is to typically comment out the section titled “Inline Styles” and then enable the “Block Styles.” I also like to move the paragraph to the top of the list. Click here for example of my fckstyles.xml file.

Obviously, there is a lot of personal preference to how content administrators should manage the content on your site. I like to be prescriptive and shepherd my content editors toward semantic markup. If you have other suggestions, let me know.

Comments

Sebastian Leupold
Saturday, June 27, 2009
Hi Patrick,
great article. I'd only suggest to perfom modifications in a copy of fckconfig.js and fckstyles.xml to avoid them being overwritten on portal upgrades.

Patrick
Saturday, June 27, 2009
Thanks Sebastian - This is the kicker for modfiying the FCKEditor - any changes get lost upon upgrading. I typically create a copy to restore the modifications after upgrades. Thanks for pointing this out.

PimpThisBlog.com
Sunday, June 28, 2009
Optimizing the FCKEditor for DNN
Thank you for submitting this cool story - Trackback from PimpThisBlog.com

David O'Leary
Wednesday, July 15, 2009
There's an error in your article, the filename should be fckconfig.js, not fckconfig.xml

Patrick
Wednesday, July 22, 2009
Thanks David - you're correct. The file to update the actions available is fckconfig.js

Lance
Tuesday, July 28, 2009
Good article. I would add the power and use of templates. This is particularity handy if you have moderately skilled users and you want to support things like hCard or style figures consistently. I also use it for elements that will interact with Jquery ensuring the classes match.

Helen Johnson
Monday, October 19, 2009
I am working on a DNN site and I have successfully gotten rid of all of the inline styles, but I'm not having luck making the block styles show up in the font style specified in my skin.css file. Any suggestions? Thanks, Helen

Patrick
Thursday, October 22, 2009
Helen - in the FCKEditor as an admin, there is an option below the editor for "Show custom editor options." In the Editor Area CSS section - make sure Dynamic is selected and then apply the setting to your Portal. Even if it is already set to Dynamic, give it another kick in the butt. Check out his link for similar conversation http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/127/threadid/128066/scope/posts/Default.aspx

Click here to post a comment