Enabling CKEditor on Publishing Sites

This website contains links to software which is either no longer maintained or will be supported only until the end of 2019 (CKFinder 2). For the latest documentation about current CKSource projects, including software like CKEditor 4/CKEditor 5, CKFinder 3, Cloud Services, Letters, Accessibility Checker, please visit the new documentation website.

If you look for an information about very old versions of CKEditor, FCKeditor and CKFinder check also the CKEditor forum, which was closed in 2015. If not, please head to StackOverflow for support.

During the installation process, CKEditor will be automatically enabled on Publishing Sites. However, if you have modified the default master pages or if you are using your own, custom master pages, then you will need to manually enable CKEditor on these sites.

Adding CKEditor to a Master Page

The master pages are located in the following folders:

  • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GLOBAL\default.master
  • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\PublishingLayouts\MasterPages\

In each file master file that is used on your sites do the following changes:

Step 1: Register an Assembly

To enable CKEditor, in the Register section at the top of the page add:

<%-- Start CKEditorForSharePoint --%>
<%@ Register TagPrefix="my" Assembly="CKEditorForSharePoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2c0483256f3286a8" 
Namespace="CKEditorForSharePoint" %>
<%-- End CKEditorForSharePoint --%>

Step 2: Add the Page_Load Method

Straight below the Register tag or somewhere in the <body> of the master page add:

<%-- Start CKEditorForSharePoint --%>
<script language="C#" runat="server">
private void Page_Load(object sender, EventArgs e) {
	this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "CKEditorConfigScript", 
		string.Format("var CKTabConfig =\"{0}\";", SPUtils.ReadConfigurationForCKEditor()), true);
}
</script>
<%-- End CKEditorForSharePoint --%>
important note

The extra comments <%-- Start CKEditorForSharePoint --%> and <%-- End CKEditorForSharePoint --%> are not required, but they will be helpful e.g. during uninstallation process or when modifying the page to understand what they are used for.


Step 3: Enable Code Blocks in Master Pages

In previous step we added server side code to the page. In order to execute this part of code, SharePoint must be configured to allow this operation. If code blocks are disallowed, you will see the following error:

 Parser Error Message : Code blocks are not allowed in this file

Code blocks can be enabled in the web.config file, in the configuration/SharePoint/PageParserPaths configuration section. Find the <PageParserPaths> option and add there <PageParserPath> element:

<PageParserPaths>
	<PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" 
		IncludeSubFolders="true"/>
</PageParserPaths>
important note
Such configuration option should be restricted only to certain set of pages (or even to a single page). Anyone that can modify or add a page to the specified VirtualPath can insert code that will be executed server side with no restrictions. A good location to specify as a PageParserPath is the location where you store your masterpages, for example /_catalogs/masterpage.