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.

(Article contents proof-read)
(Validity note aded)
 
Line 2: Line 2:
 
{{#CUSTOMTITLE:Enabling CKEditor on Publishing Sites}}  
 
{{#CUSTOMTITLE:Enabling CKEditor on Publishing Sites}}  
 
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, you will need to manually enable CKEditor on these sites.
 
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, you will need to manually enable CKEditor on these sites.
 +
 +
<note>Please note that this instructions are valid for all CKEditor for SharePoint versions '''starting from 1.3 rev.3'''.
 +
</note>
 +
  
 
== Adding CKEditor to a Master Page ==
 
== Adding CKEditor to a Master Page ==

Latest revision as of 15:01, 11 January 2012

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, you will need to manually enable CKEditor on these sites.

important note

Please note that this instructions are valid for all CKEditor for SharePoint versions starting from 1.3 rev.3.


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\

For each master file that is used on your sites you need to introduce the changes described below.

Step 1: Register an Assembly

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

<%-- 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

Add the following code straight below the Register tag or somewhere inside the <body> of the master page:

<%-- 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 in the form of <%-- Start CKEditorForSharePoint --%> and <%-- End CKEditorForSharePoint --%> are not required, but they will be helpful e.g. during the uninstallation process or when modifying the page to understand what they are used for.


Step 3: Enable Code Blocks in Master Pages

In the previous step we added some 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 configuration/SharePoint/PageParserPaths configuration section of the web.config file. Find the <PageParserPaths> option and add an <PageParserPath> element there:

<PageParserPaths>
	<PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" 
		IncludeSubFolders="true"/>
</PageParserPaths>
important note
Such configuration option should be restricted only to a 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 on the 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.
This page was last edited on 11 January 2012, at 15:01.