Kentico CMS 7.0 Developer's Guide

Web part inheritance

Web part inheritance

Previous topic Next topic Mail us feedback on this topic!  

Web part inheritance

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

Web part inheritance allows you to create a web part that has the same properties and uses the same code as the original web part, but has different default property values. It means you can create a specialized web part from a general one.

 

For example: You can create a news list web part inherited from the Repeater web part that will display a list of news by default. The default values can later be modified to any other value, but the inherited (specialized) web part allows you to do things faster.

 

How to create an inherited web part

 

1. Go to Site Manager -> Development -> Web parts, select the Listings and viewers category and click NewWebPart New web part.

 

2. Choose Inherit from an existing web part and enter the following values:

 

Display name: Custom news list

Code name: CustomNewsList

Inherit from: Listings and viewers/Documents/Repeater

 
Click Save Save.
 

3. Switch to the Properties tab of the newly created web part. Here you can see the properties of the parent web part and you can override their default values by clearing the Inherited box and entering a new default value. Enter the following default values:

 

Path: /%

Document types: cms.news

ORDER BY expression: NewsReleaseDate

Transformation: cms.news.preview

Selected item transformation: cms.news.default

 

Click Save Save.
 

devguide_clip1230
 

4. Go to CMS Desk, choose the Home page in the content tree and switch to the Design tab. Add the News list web part to the page. It will now display all site news without any additional configuration.