Sample Generic Content based module: Products module

March 11, 2009 Digital Experience

[This post is part of the developer's manual preview published on this blog. You can find temporary TOC here.]

 

 

In this article we are providing a sample Products module which is based on Generic Content module. The Products module supports following features:
  • Dynamic meta fields
  • Hierarchical categories
  • Tagging
  • Comments
  • Permissions
  • History (rollback)
  • Localization
  • Embedded templates
Generally speaking, it takes about 3-4 hours to build such a module and if the requirements for your module are similar to the features provided by Generic Content module, this is by far the simplest and fastest way to build a new module. We will explore different aspects of this approach in the articles to come.

 

You can download the module from here.

 

Installation instructions:
  • Download the module from here (if you haven't already)
  • Open an existing or create new Sitefinity website
  • Paste the contents of the Website folder in the root of your website (if asked to overwrite, say yes).
  • Add Telerik.Samples.Products project to your website, thus creating a solution (go to File > Add > Existing Project… Navigate to the Telerik.Samples.Products.csproj file that came with this sample)
  • Expand the References folder in the Telerik.Samples.Products and fix reference problems if any (this can happen if your website is using a different version of Sitefinity than the one I used to create a sample)
  • Reference Telerik.Samples.Products project from your website (right click on the website in the Solution Explorer, select “Add Reference…”, select “Projects” tab and then select the Telerik.Samples.Products from the available projects. Click OK.
  • Register the products configuration section by pasting the following line in the web.config file as an immediate child of <sectionGroup name=”telerik”>:
    <section name="products" type="Telerik.Samples.Products.Configuration.SectionHandler, Telerik.Samples.Products" requirePermission="false" />
  • Register Products module by pasting following line as an immediate child of telerik/framework/modules section:
    <add type="Telerik.Samples.Products.ProductsModule, Telerik.Samples.Products" /> 
  • Add new Generic Content provider by pasting following line as an immediate child of the telerik/cmsEngine/providers section:
    <add name="Products" urlRewriteFormat="[Name].aspx" urlWhitespaceChar="_" visible="False" defaultMetaField="Name" securityProviderName="" allowVersioning="True" applicationName="/Products" versioningProviderName="" allowComments="false" commentsModeration="true" connectionStringName="GenericContentConnection" type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data"></add> 
  • Declare the metafields for the products module by pasting following lines as an immediate child of telerik/cmsEngine/metaFields:
    <add key="Products.Name" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="Name this content" mandatory="True" /> 
    <add key="Products.Price" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" /> 
    <add key="Products.SKU" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" /> 
    <add key="Products.Weight" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" /> 
    <add key="Products.Category" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" /> 
     
  • Declare the products module section by pasting following lines as an immediate child of telerik/cmsEngine section:
    <products defaultGenericProvider="Products"
          <genericContentProviders> 
            <add providerName="Products" urlRewriteFormat="[Name].aspx" urlWhitespaceChar="_" /> 
          </genericContentProviders> 
    </products> 
     
  • Save web.config file, build your solution and run it. Products module will be available in the Modules section.
In case you have any questions or run into problems, please let us know. Also if there are some features that you would like explained in more detail, do not hesitate to leave a comment. Your feedback is greatly appreciated.

 


The Progress Team