(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…') |
(No difference)
|
Revision as of 12:52, 16 December 2011
Contents
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 --%>
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>
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
.