In nopCommerce you can specify an alternate layout template for a category, manufacturer, product and topic. You can see a list of the existing templates on the System → Templates page:
By default, there is one category template, one manufacturer template, one topic template and two product templates in the system.
Each category, manufacturer, product and topic details page in admin area allows you to choose the template when editing an entity. For example:
You will see the template dropdown list only if you have more than one tepmlate created for categories, manufacturers and topics.
Since we have two product types, Simple and Grouped (product with variants), we have two appropriate product templates created by default:
Therefore, to see the template dropdown list on the product details page you need to create two product templates that fit the choosen produt type. Read how to do this below.
Add a new template
Let's see how to create a template on the product template example. Let's say you want to create it for the Simple product type.
First of all, you need to create an appropriate template file. Skip this step if you already have one placed in the right folder.
- Go to the
- Copy the
ProductTemplate.Simple.cshtmlfile and rename it. Let's say it will be
- Modify the code of the
ProductTemplate.MyNewOne.cshtmlfile to fit your needs.
- Go to the
Go to the System → Templates page and proceed to the Product templates panel:
In the Add new record block fill the following form:
Enter the Name of the template. In our case it's
My New One.
Enter the View path. In our case it's
Enter the Display order of this template. 1 represents the top of the list.
For the product template only. Not applicable for other templates: Enter the Ignored product type IDs (advanced). By default, we have two product types and appropriate product type IDs: Simple (ID 5) and Grouped (ID 10). Since we create a template for the Simple product type we should ignore the Grouped product type with ID 10.
So the form will look the following way:
Click the Add new record button to save the new template.
After you save the new template you will see it on the product details page and now you can choose from two product templates:
It's not required to restrict a product template using the Ignored product type IDs (advanced) field. If you leave this field empty you will be able to use the product template for all types of products.