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: http://jotcms.codeplex.com/releases/54680/download/161802

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.
<pages>
      <namespaces>
        <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" />
      </namespaces>
    </pages>

Slightly different syntax for MVC3 with Razor
<system.web.webPages.razor>
    <pages pageBaseType="">
      <namespaces>
        <add namespace="JotCMS" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

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

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

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">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
      <httpRuntime requestValidationMode="2.0"></httpRuntime>
    </system.web>
  </location>

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>
    <p>
        To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
    </p>

    <%= Html.RenderJotContent("TestContent") %>
</asp:Content>

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

Comments

No comments yet.