Kentico CMS 6.0 Tutorial  

News page

News page

Previous topic Next topic Mail us feedback on this topic!  

News page

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

Click /News in the content tree. The News page is ready to use since it uses the pre-defined News list page template. Click New, choose to create a News document and enter the following text:

 

News title: News 1

Release date: click the date-time picker and click Now and click OK.

News summary: News 1 summary.

News text: News 1 text.

Teaser, Publish from/to: leave the fields blank.

 

Click Save and create another. Enter the following values:

 

News title: News 2

Release date: click the date-time picker and click Now and click OK.

News summary: News 2 summary.

News text: News 2 text.

Teaser, Publish from/to: leave the fields blank.

 

Click Save Save.

 

When you click /News and Live site now, you will see the list of news under the News section:

 

tutorial_clip0114

 

As you can see, the main /News page 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:

 

tutorial_clip0115

 

The breadcrumbs now show the current path on the website: News > News 1. The position is also reflected in the URLs:

 

The URL of the News page is /news.aspx

The URL of the News 1 page is /news/news-1.aspx

 

This makes the website more accessible to both people and search engines, such as Google.

 

You might wonder how the listings are displayed by Kentico CMS. Let's explain it on this page: Click /News, click Edit and choose the Design tab. Edit the properties of the NewsRepeater web part. This web part displays the list of documents. It's actually based on the standard ASP.NET Repeater control that you may already know.

 

tutorial_clip0116

 

The most important properties are these:

 

Path - this property says where the content to be displayed is located in the content tree. If you leave the value empty, it searches for documents under the current page.

Document types = cms.news - this property says what type of documents should be displayed (news/products/jobs/etc.).

Transformation = cms.news.preview - this property says which transformation should be used to render the displayed items. The transformation works similar to the ItemTemplate element that you would normally use with a Repeater control. Transformations can be managed in the Site Manager -> Development -> Document types -> ... edit document type ... -> Transformations interface.

Selected item transformation = cms.news.default - this property says which transformation should be used for the detail view of the selected document.

Paging - if you plan to have a large amount of news items on a single page, you can configure automatic paging using this property.

 

How it works

 

1.You go to the /News page.

2.The NewsRepeater web part checks if you have selected some particular news item (based on its Document types property value).

3.It finds out that you have selected a page document, so it looks for all underlying news documents and displays them as a list using the cms.news.preview transformation.

4.When you select some particular news item, such as /News/News 1, the NewsRepeater web part uses the cms.news.detail transformation instead and displays the details.

 

 

 

Path expressions

 

The Path property in web parts supports the following special expressions that allow you to select the content dynamically:

 

/%

All documents on the website.

/news/%

All documents under /News.

/news/news1

The News1 document.

./%

All items under the current document.

./logo

The Logo document under the current document.

./images/%

All images under the Images child document.

../contacts/%

All documents under the Contacts document on the same content level.

/{0}/%

All documents under the current first level document.

 

Example: if the currently selected document is

/news/news1

the expression is evaluated as

/news/%