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.

(Created page with '{{#CUSTOMTITLE:Enabling CKEditor on Publishing Sites}} __TOC__ During the installation process, CKEditor will be automatically enabled on Publishing Sites. However, if you have m…')
 
(Article contents proof-read)
Line 1: Line 1:
{{#CUSTOMTITLE:Enabling CKEditor on Publishing Sites}} __TOC__
+
__TOC__
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.
+
{{#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.
=== Adding CKEditor to a Master Page ===
 
  
 +
== Adding CKEditor to a Master Page ==
 
The master pages are located in the following folders:
 
The master pages are located in the following folders:
 
* <code>C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GLOBAL\default.master</code>
 
* <code>C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GLOBAL\default.master</code>
 
* <code>C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\PublishingLayouts\MasterPages\</code>
 
* <code>C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\PublishingLayouts\MasterPages\</code>
  
In each file master file that is used on your sites do the following changes:
+
For each master file that is used on your sites you need to introduce the changes described below.
  
==== Step 1: Register an Assembly ====
+
=== Step 1: Register an Assembly ===
 
+
To enable CKEditor, add the following code in the <code>Register</code> section at the top of the page:
To enable CKEditor, in the <code>Register</code> section at the top of the page add:
+
<source lang="asp">
 
 
<source>
 
 
<%-- Start CKEditorForSharePoint --%>
 
<%-- Start CKEditorForSharePoint --%>
 
<%@ Register TagPrefix="my" Assembly="CKEditorForSharePoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2c0483256f3286a8"  
 
<%@ Register TagPrefix="my" Assembly="CKEditorForSharePoint, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2c0483256f3286a8"  
Line 21: Line 19:
 
</source>
 
</source>
  
==== Step 2: Add the Page_Load Method ====
+
=== Step 2: Add the Page_Load Method ===
 
+
Add the following code straight below the <code>Register</code> tag or somewhere inside the <code><body></code> of the master page:
Straight below the <code>Register</code> tag or somewhere in the <code><body></code> of the master page add:
+
<source lang="asp">
<source>
 
 
<%-- Start CKEditorForSharePoint --%>
 
<%-- Start CKEditorForSharePoint --%>
 
<script language="C#" runat="server">
 
<script language="C#" runat="server">
Line 36: Line 33:
  
 
<note>
 
<note>
The extra comments <code><%-- Start CKEditorForSharePoint --%></code> and <code><%-- End CKEditorForSharePoint --%></code>  
+
The extra comments in the form of <code><%-- Start CKEditorForSharePoint --%></code> and <code><%-- End CKEditorForSharePoint --%></code> 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.</note>
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.
 
</note>
 
 
 
  
==== 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:
+
=== 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
 
   '''Parser Error Message''' : Code blocks are not allowed in this file
  
Code blocks can be enabled in the <code>web.config</code> file, in the <code>configuration/SharePoint/PageParserPaths</code> configuration section. Find the <code><PageParserPaths></code> option and add there <code><PageParserPath></code> element:
+
Code blocks can be enabled in the <code>configuration/SharePoint/PageParserPaths</code> configuration section of the <code>web.config</code> file. Find the <code><PageParserPaths></code> option and add an <code><PageParserPath></code> element there:
  
 
<source lang="xml">
 
<source lang="xml">
Line 56: Line 50:
 
</source>
 
</source>
  
<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 <code>VirtualPath</code> can insert code that will be executed server side with no restrictions. A good location to specify as a <code>PageParserPath</code> is the location where you store your masterpages, for example <code>/_catalogs/masterpage</code>.</note>
+
<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 <code>VirtualPath</code> can insert code that will be executed on the server side with no restrictions. A good location to specify as a <code>PageParserPath</code> is the location where you store your masterpages, for example <code>/_catalogs/masterpage</code>.</note>

Revision as of 15:26, 16 December 2011

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.

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.