Note: I'm working on NuPack support so none of this manual web.config editing should be needed in the future. NuPack will configure this all.

Click this link to download a demo solution:

First we setup your project to be able to use JotCMS with five steps, then use it.

JotCMS Folder Copy

Copy the folder JotCMS and all it's contents inside your project.

Web.Config Changes

1. Add connectionstring and call it JotCMS
<add name="JotCMS" connectionString="Data Source=<server>;Initial Catalog=<DatabaseName>;Integrated Security=True;" />

2. Add the namespace of JotCMS so you can use it in any of your Views.
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="JotCMS" />

Slightly different syntax for MVC3 with Razor
    <pages pageBaseType="">
        <add namespace="JotCMS" />

3. Add a configSections (if you don't already have one) and add this new <sectionGroup> for JotCMSGroup.
    <sectionGroup name="JotCMSGroup">
      <section name="JotCMSConfiguration" type="JotCMS.JotCMSConfiguration"/>

4. Add the configuration for JotCMSGroup into the root node of <configuration> (next to configSections is fine)
    <JotCMSConfiguration ConnectionStringName="JotCMS" Cache="true" CacheDuration="720" EditorRoles="*"></JotCMSConfiguration>

Note: EditorRoles. * = everyone, ? = authenticated users only, or roles if your application is using them such as "ContentEditor". Multiple roles supported, just seperate them by commas.

5. Add Location section for JotCMS. For <allow users> node, add whatever role you want to be able to edit content, such as Admin. Ensure you include <httpRuntime requestValidationMode="2.0"></httpRuntime>. This is for security reasons, which will allow you to save content with HTML tags.
<location path="JotCMS">
        <allow users="*" />
      <httpRuntime requestValidationMode="2.0"></httpRuntime>

Now Use It!

Everything is ViewHelpers. Add one called <%= Html.RenderJotEditControl()%> anywhere on your view that wants to use it. This includes some core stuff as well as the Edit Control. Now add <%= Html.RenderJotContent("TestContent") %> wherever you want controlled content. "TestContent" being whatever you want to name your content.
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
     <%= Html.RenderJotEditControl()%>
    <h2><%: ViewData["Message"] %></h2>
        To learn more about ASP.NET MVC visit <a href="" title="ASP.NET MVC Website"></a>.

    <%= Html.RenderJotContent("TestContent") %>

Last edited Oct 29, 2010 at 1:49 AM by jordan112, version 16


No comments yet.