Kentico CMS 7.0 Tutorial ASPX

Page template

Page template

Previous topic Next topic Mail us feedback on this topic!  

Page template

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

This topic describes how to create the product list page and publish computer specifications on the website.

 

Preparing the ASPX source file for the products template

 

1. Edit your web project in Visual Studio, right-click the CMSTemplates/MySite folder in the Solution Explorer and click Add new item.

 

2. Create a Web Form named ProductList.aspx and check the Select master page box.

 

tutorial_clip0170

 

3. Click Add and choose the MyMaster.master page from the CMSTemplates/MySite folder.

 

tutorial_clip0166

 

4. Drag the following controls inside the <asp:Content> element of the product list page:

 

CMSBreadCrumbs

CMSDataList

 

If you view the web form on the Design tab, you should see the structure of the page as shown below:

 

tutorial_clip0171

 

5. Set the properties of the CMSDataList control according to the table below:

 

Property

Value

Description

ClassNames

custom.computer

Configures the datalist to display only documents of the custom.computer type (created in the New document type topic).

OrderBy

ComputerName ASC

Sets the SQL ORDER BY clause that the control uses when loading data. As a result, the control displays items in ascending alphabetical order based on the ComputerName values.

TransformationName

custom.computer.preview

Assigns the transformation that the datalist uses to display the list of computer products (as defined in Transformations).

SelectedItemTransformationName

custom.computer.default

When a user selects a specific computer document on the website, the control displays the details according to the specified transformation.

RepeatColumns

2

Configures the datalist to display 2 items per row in list mode.

 

6. Switch to the code behind of the product list page (ProductList.aspx.cs) and add a reference to the CMS.UIControls namespace:

 

[C#]

 

using CMS.UIControls;

 

[VB.NET]

 

Imports CMS.UIControls

 

7. Change the class definition so that it inherits from the TemplatePage class:

 

[C#]

 

public partial class CMSTemplates_MySite_ProductList : TemplatePage

 

[VB.NET]

 

Partial Class CMSTemplates_MySite_ProductList

  Inherits TemplatePage

 

8. Save the files.

 

Registering the page template

 

The source files of the product list page are ready. Now you need to register the page template in Kentico CMS.

 

1. Go to Site Manager -> Development -> Page templates.

 

2. Select the My website category and click AddTemplate New template.

 

3. Type Product list into the Template display name field and click Save Save.

 

4. Set the following values on the General tab:

 

Template type: ASPX page

File name: ~/CMSTemplates/MySite/ProductList.aspx

 

5. Click Save Save.

 

6. Switch to the Sites tab and assign the page template to My website.

 

Adding the products section

 

1. Go to CMS Desk -> Content. Select the root of the content tree (My website) and click New.

 

2. Choose the Page (menu item) document type.

 

3. Type in Products as the Page name and choose the Use existing page template option. Select the My website category and the Product list page template.

 

4. Click Save Save to create the page.

 

5. Select the Products page in the content tree, click New and choose the Computer document type.

 

6. Fill in the computer document fields with the following values:

 

Computer name: Home PC Dallas

Processor type: Athlon

RAM (MB): 2048

HDD (GB): 160

Image: upload an image (you can find sample images in the <Kentico CMS installation>\CodeSamples\SampleWebTemplate\Computer_Images folder)

Publish from/to: leave the values blank

 

7. Click SaveAndAnother Save and create another and enter the following values:

 

Computer name: Office PC Houston

Processor type: Pentium Core 2 Duo

RAM (MB): 4096

HDD (GB): 200

Image: upload an image (you can find sample images in the <Kentico CMS installation>\CodeSamples\SampleWebTemplate\Computer_Images folder)

Publish from/to: leave the values blank

 

8. Click Save Save.

 

If you view the /Products page in Live site mode, you can see a list of the two computer products (formatted according to the custom.computer.preview transformation):

 

tutorial_clip0132

 

When you click the title of a specific computer, the page displays the detail view (using the custom.computer.default transformation):

 

tutorial_clip0133