In the previous topic about simple implementation of the Products module, we have implemented a simple Products module
based on the Generic Content module. In this sample, we are taking that sample to the next step and we are going to enable categorization of products. Since Generic Content
module supports categories by default our task will be very simple.
There are two basic tasks we need to perform:
- Add categories support to Admin side of our module
- Add categories support to Public side of our module (ProductsView control)
Add Categories Support to Admin Side of Simple Products Module
In order to add categories support to admin side we will need to register a new meta key for our module ("Category"), add the link to CategoriesManagement in
CommandPanel and, finally, add the controls in ControlPanelInsert and ControlPanelEdit templates that users will use to assign a
product to a category.

Figure 1 – Categories Management on admin side
Add Categories Support to Public Side of Simple Products Module
By adding categories support to public side, we mainly think of modifying the ContentViewItemList and ContentViewSingleItem templates. We need
to add Hyperlink control with the ID “Category” (same as the meta key we have defined in web.config). In addition to this, we will also add
CategoriesList control and synchronize the CategoryKey properties of ProductsView and CategoriesList controls,
so that both properties have the value of "ProductsCatID".

Figure 2
Code Sample
You can download the full code sample for "Products module with Categories" from here.
In order to set up a project, please do following:
- Download the project from here (if you haven’t done that already)
- Follow the instructions for setting up simple implementation of this module, provided in this section (last part of the topic)
- Add additional meta key to Products module for Category. The line you should add to web.config should look like this:
| web.config |
Copy Code |
|
<add key="Products.Category" valueType="ShortText" visible="True" searchable="True" sortable="True"
defaultValue="" />
|
- In order to make ProductsView control work together with CategoriesList control, do the following:
- Create a new page
- Drag ProductsView control on the page
- Drag CategoriesList control on the page
- Edit CategoriesList control
- Set the provider name to "Products" (without double quotes)
- Set the CategoryKey property to "ProductsCatID" (without double quotes)
- Edit ProductsView control
- Make sure that the value of CategoryKey property is "ProductsCatID" (without double quotes)
See Also