Sitefinity CMS

Overview Send comments on this topic.
See Also
Developing with Sitefinity > Modules > Adding New Modules to Sitefinity > Generic Content Based Module > Overview

Glossary Item Box

Implementing Generic Content based module


As its name suggests, Generic Content module is a module that was built for working with content in general. Since Sitefinity is a Content Management application, chances are majority of the modules you will build will need same or similar features provided by Generic Content module. Building a module based on Generic Content module will drastically reduce the amount of time and code you will need in order to implement your module. In fact, many of our built-in modules are built on top of Generic Content module and reuse the features offered by it. Some examples are:

  • News module
  • Events module
  • Blogs module
  • Images & Documents module

What are the features offered by Generic Content module that you can reuse?


There are many features that are implemented directly on the Generic Content module so that they can be reused across all modules based on it. Here is the list of more important features that other modules can reuse (don’t worry if you are unsure how all this works – there will be specialized samples for each of the features):

  • Dynamic metafields
    Any Generic Content based module can have dynamic meta fields attached to each content object. The meta fields are defined in web.config and require no additional coding (in terms of data access layer and persistence). So, for example, News module has meta fields such as “Author”, “Source”, Blogs module has meta fields such as “Title”, “Publication date”. To create different meta fields, a simple modification in web.config will suffice (and of course UI modification).
  • Categories
    Generic content module provides ability to categorize content out of box. So whatever type of content that you will be creating, you can allow end users to categorize it with no additional work needed.
  • Tags
    Similarly to Categories, Generic Content also provides built in support for tagging of content. No additional work will be needed here as well.
  • Comments
    If you wish to allow the visitors to comment on the content your module will generate, again, you can take advantage of the built in commenting system.
  • Permissions
    Your Generic Content based module can also take advantage of the built in permissions, so that you can define which users can do what. Once again, no additional coding required!
  • Workflow
    Generic Content based modules also come with built in ability to control the workflow of content creation. So the content items your module will manage can go through stages such as Draft, Waiting for approval, Published and so on.
  • Localization
    When you build module based on Generic Content you will also have out of box option to localize content, in the same manner News or Blogs module do so. And yes… with no additional coding.
  • Production ready public base control
    When you build a module based on Generic Content you will have the ability to build your public controls on top of Content View control, which is a production ready, powerful and extensible control for displaying your content items on the public side of the website. You will automatically get the paging, sorting and filtering features (and many more actually), that you can reuse as they are or override and provide your own implementation. To demonstrate the flexibility of this control, it is enough to say that standard Sitefinity controls, such as News View, Blog Posts and Events View are all based on Content View (even though they appear quite different).
  • Extensible - ready made public control designers
    When you are developing your public controls based on the Content View control you can also take advantage of our extensible Content View designers, which will make the process of creating user friendly control designer a breeze. In addition to this, you can simply plug in new settings for the designer with minimum amount of code.
    So, as you can see, building a module based on Generic Content may prove advantageous for many reasons. But, there is also another reason why you may want to build your module based on the Generic Content module – namely, Generic Content module is one of the pillars of Sitefinity and as such it is constantly being improved and new features are being added. If your module is based on Generic Content module you will be able to very easily take advantage of all new improvements in the next version.

So, how all this works in real world?


 

Basically whenever you need a functionality that will create some kind of content which will be publicly displayed, you may want to consider implementing Generic Content based module. There are, of course, situations when implementing a Generic Content based module would not make sense – modules whose functionality goes well beyond creating and displaying content (e.g. forums, form builder, payroll etc.).

Nevertheless, in a large number of occasions Generic Content based module may be the way to go – and avoid reinventing the wheel along the way.

To demonstrate how to implement Generic Content based module we are going to build “Products” module which will be based on Generic Content. The purpose of the module is to provide a catalog of products on the website. The samples will be provided in several versions, each taking focus on specific features of Generic Content based module. The final example will be a full blown “Products” module with all features of Generic Content module used and showcased.

 

Here is the list of samples:

NOTE: At the moment think of this more as of a roadmap. The time has not allowed us to provide all the samples at this time – however all the samples should be available by the end of August 2008.
  • "Products" module – simple implementation
    Basic implementation – the only change we have done here is added some additional meta fields we need to display the information on products.
  • "Products" module – simple implementation with enabled categories
    Same as simple implementation, but this time we have allowed management of categories on the admin side and on the public side we have implemented Categories list control.
  • "Products" module – simple implementation with enabled tags
    Same as simple implementation, but this time we have allowed tagging on content items. On the public side we have implemented Tags list control
  • "Products" module – simple implementation with enabled comments
    Same as simple implementation, but this time we have allowed commenting of the products. Also, the comments management has been enabled on the admin side.
  • "Products" module – simple implementation with enabled permissions
    Same as simple implementation, but this time permissions for creating, modifying, viewing, editing and permission setting have been enabled.
  • "Products" module – simple implementation with enabled permissions and workflow
    This implementation is very similar to the previous one with permissions, but in addition workflow permissions have been added and workflow for the module has been turned on.
  • "Products" module – simple implementation with enabled localization
    Same as simple implementation, but this time we have enabled localization of products.
  • "Products" module  - simple implementation with ContentViewDesigner implemented on public ProductsView control
    Same as simple implementation, but this time we have implemented simple ContentViewDesigner public control on the ProductsView control
  • "Products" module – full- fledged version
    Finally, we’ll put all the pieces together and create a full-fledged “Products” module with all of Generic Content features.

See Also