News page |
Top Previous Next |
Now we will create the News section of our web site. Go to Visual Studio and create a new web form in the CMSTemplates\MySite folder, call it NewsPage.aspx, check the Select master page box and click Add. Choose the MyMaster.master master page and click OK.
Switch to the Design tab, drag and drop and configure the following controls:
CMSBreadCrumbs (no properties to be set)
CMSRepeater
Switch to the HTML mode and add the following HTML code between both controls:
When you switch back to the Design tab, you should see a page like this:
Switch to the code behind and add reference to the CMS.UIControls namespace:
[C#]
[VB.NET]
You also need to change the class definition so that it inherits from the TemplatePage class:
[C#]
[VB.NET]
Save all changes.
Page Template Registration
Go to Site Manager -> Development -> Page templates, click the My web site category and click New template. Create a new page template with following details:
On the detail page, please choose:
Switch to the Sites tab and assign the template to My web site.
Go to CMS Desk -> Content, click root and click New. Choose to create a new Page (menu item) using the My web site/My news template page template and call the page News.
Click Save. Click the News page and click New, choose to create a news document and enter the following text:
Click Save and create another and enter the following values:
When you click /News and Live site now, you will see the list of news under the News section:
As you can see, the main page /News displays the list of the news items that are placed under it. This is an example of how the content is logically structured in Kentico CMS. When you click /News/News 1 now, you will see the detail view:
The breadcrumbs now show you current path on the web site: News > News 1. The position is also reflected in the URLs:
This makes the web site more accessible to both people and search engines, such as Google.
How it works
When you click on some particular news item, such as /News/News 1, the NewsRepeater web part uses the cms.news.default transformation instead and displays the detail view.
|