Blog

Tips for Creating Page Types in Kentico

by Joel Dahlin on July 24, 2016

Tips for Creating Page Types in Kentico

Custom Page Types is one of the core features in Kentico. Here we're going to cover more than the basics. Using some added features with a few best practices makes it fool proof for content editors to add content.

Walking through the add new Page Type:

Step 1

Page Display Name
We always name our Page Types prefixing them with the site name and a dash. "DahlinDev - Blog Post Demo". This will group all the Page Types for sites in the list making them easier to find.

Code name - the combination of the Namespace and Name creates the sql table name by default, namespace_name.

  • Namespace the name the same as the site name, ie. "dahlindev". We always lowercase the namespace.
  • An Identifiable name for the Page Type, ie, "BlogPostDemo".

Step 2

Here you need to decide how your Page Type will be used.

  • A page - if your Page Type is meant to be an actual page the defaults are fine. This is most often the case.
  • Content Only - Sometimes you want to create a Page Types simply to hold content for a parent page or another page. An example may be for a carousel on a page. You may want to create a "Slide" page type that has fields for an Image, Text, and Link. The purpose of the page type is for the parent to use the content from this page, there is no actual page meant for adding these in the content tree. These make it nice for the editor since they won't see a Page tab at all. The page will not have a url but also cannot be converted to a regular page later on.
    Another way I'll use it is for a container where I want to control the name of it. Lets say I want a "DahlinDev - [Carousel]" page type. Whenever this page is added I want it to be called "carousel" The content editor needs to add this to be able add Slides below it. I'll discuss this more in Step 3.
    The reason I like to use containers is to keep the content tree organized so "content" pages aren't mingled in with regular pages. I often will create an overall "Page Content" page type that below it only allows specific content container types. This combined with "Alllowed Types", Step 5, really makes it easy for content editors.
  • Container without custom fields - self-explanatory, it is basically a folder with only a name field. An example would be to create one that is used just for custom transformations.
  • *Notice I put [] Carousel. I do this so I can easily identify container page types.

Step 3 - Fields

  • Image fields - in the Field Caption add the expected dimensions of the image, ie. "Avatar [75x75]" this makes it easy for the editor to know what size of an image to add.
  • ID field - sometimes there are pages that don't have any required fields. In that case I'll add an additional field called "Name" with a caption of "Name [ID]". Then in training I will let the editors know that on these fields it is only there to identify it in the content tree. Yes, Kentico does have the "Name" field by default if there aren't any required fields, but in this case the editor knows the only purpose of the field is for the content tree by the [ID] name. This field is used for the Page name Source (Step 4).
  • Back to Step 2 in my example of creating a "DahlinDev - [Carousel]" page type which is a content only type. I'll add one field called "Name". Make it required, set the Default value = "carousel" and leave the Field Caption blank. For the Form Control I set it to a label. Now when an editor adds a new page of this page type it is basically a confirmation that they're adding it. I'll have a Page Template with a repeater on it with a Path = "./carousel/%". This ensures the path will be "carousel" taking away the ability of the content editor to name it something different. 

Step 5 - Parent types

It's important to take the time to add only the page types you want this page type to be added below. This makes it dead simple for content editors to know what can be added. In my carousel example, if I were creating the "DahlinDev - Slide" page type I would only allow the "DahlinDev - [Carousel]" page type. Now when a content editor adds a new page under a "DahlinDev - Carousel" it will bring them right to the form of a "DahlinDev - Slide" by passing the selection of why type of Page Type to add.

Step 6 - Sites

Just need to make sure you're adding to the right site, this generally is left as-is.

Step 7 - Finish

There are a couple more things I will do after the initial creation though.

 

General

After clicking the finish button you will be brought to the General page of the Page Type.

Here I like to update the "Page type icon". This will change the icon of the page in the content tree to make it easy to see what type of page it is. I usually pull something from the Kentico icons found here, http://devnet.kentico.com/docs/icon-list/index.html. Just find something that makes sense, copy the class and replace "icon-doc-o" with it. It's an easy way to visually help your editors.

More often than not a Page Type will have a one-to-one relationship with a Page Template. For example maybe you're creating an "Author" page template and you also have an "Author" page type. Once that page template is created I'll go back and update the Default page template found on the General tab to that page template. Now when a new page is added it automatically uses the Author page template. This removes a step and a decision the content editor has to make.

Scopes

A good use of this is for listing pages, for example the Articles page on the Dancing Goat site. While this listing page may just be a Page (menu item) page type, you may want to only allow "Article" page types below it in this location. Under Page Types you can create a new Scope under Scopes. Now only an "Article" can be added in this location.

I urge you to read Kentico's documentation on creating page types here, https://docs.kentico.com/display/K9/Page+types for a complete understanding.

Using these tips really makes it easier for the content editor, they'll thank you for it. Do you have any additional tips to share? I'm always looking for ways to make it easier on the content editor.

 

#"page type"

Comments
Blog post currently doesn't have any comments.
 Security code