Using multiple page placeholders in Portal engine


Kentico CMS 5.5 contains one nice, so far undocumented prototype that allows you to use multiple page placeholders on your portal engine pages. Let's see how you can use it ...

Hi there,

As we are wiping out the limitations between the two development models we offer, we are working on some prototypes that would get rid of your concerns.

One of them is support for multiple page placeholders on your portal templates. So far, it seems like it is working as expected, so I thought you deserve to know already and give us some feedback on it. Before you start using it, please note following:

  • It is a prototype and was not fully tested, so it may not work under certain specific scenarios. Update: This approach is obsolete and was not tested on newer Kentico versions (8+) and may also not work correctly together with widgets
  • Since it is not an official feature, the 7 days bug fixing policy may not apply to it if the potential fix would be too complicated

Let's first see what is the difference between 5.0 and 5.5 ...

Multiple page placeholders in 5.0

If you placed multiple page placeholders to the template in 5.0, they basically were filled with the same content which is not what we typically want.

Parent layout in this example uses standard 3 column layout, and there are 2 page placeholders plcLeft and plcRight on the left and right columns. It will be the same in the 5.5 example.

Child layout is a simple layout containing some web parts:

<cc1:CMSWebPartZone ID="zoneLeft" runat="server" />

As you can see, both placeholders are displaying the same content.

In order to make the content somehow different, you had to use the default template property of the page placeholder and display the content with some other specific template. But in the situation you want to store the content to the given template and for example be able to change some area in the header from sub page, it required additional programming or use of ASPX templates development model.

Multiple page placeholders in 5.5

In 5.5, you can divide your layout into several groups similar way how you do it within ASPX master pages.

The parent layout stays the same, standard 3 columns layout with those two placeholders plcLeft and plcRight:

If you use the previous child layout and content, you get slightly little difference, basically the system identified that there are more placeholders and it does not make sense to populate all of them with the duplicate content so it populated only one (not necessarily the first one on the page flow).

What we need to do is change the layout to tell that it divides the content to several groups that target specific areas, so we change the layout to following:

<cms:CMSContent runat="server" id="cntLeft" PagePlaceholderID="plcLeft">
  <cc1:CMSWebPartZone ID="zoneLeft" runat="server" />
<cms:CMSContent runat="server" id="cntRight" PagePlaceholderID="plcRight">
  <cc1:CMSWebPartZone ID="zoneRight" runat="server" />

As you can see, each content group targets placeholder with specific ID. And what we get in design mode is that each of that content section is ported over to the appropriate placeholder:

Now we are able to edit each one individually, as a single template containing multiple placeholders. You can do the same with the master page and its sub pages to just be able to get as much control over header / footer / side columns as you want.

Just a few notes

There are some additional rules that you should know so you know how the system behaves under certain circumstances:

  • There is always only one "active" page placeholder, providing the actions in its header. That is because we are working with only one template. We will call it Default placeholder in the next text. Default placeholder is chosen indeterministically, it is the first one that is found in the internal list of placeholders under current level.
  • Any part of the layout that is not encapsulated in the CMSContent tags stays in the Default placeholder.
  • Any CMSContent part that doesn't find the placeholder with the defined ID is hidden by default
  • You may optionally set the CMSContent to be displayed even when target placeholder is not found, in that case it will be displayed in default placeholder. You can use it in case you combine multiple placeholders templates with single ones
  • <cms:CMSContent runat="server" id="cntNotExist" PagePlaceholderID="plcNotExist" ShowWhenTargetNotFound="true">
  • If you want to propagate placeholder from master page to some deeper level than the immediate one, all templates on the path to it must contain such placeholder (the system needs to know where it belongs). The CMSContent sections searches the placeholder only on the same level of visual inheritance
  • The placeholders can be branched across pages, using some tree structure, the search for them does a horizontal cut on that tree and is able to find all placeholders on the same level no matter how they got there.

And that is all, enjoy, and give me some feedback if it solves your needs for multiple placeholders.

See you next time ...

Share this article on   LinkedIn

Martin Hejtmanek

Hi, I am the CTO of Kentico and I will be constantly providing you the information about current development process and other interesting technical things you might want to know about Kentico.


Martin Hejtmanek commented on

Hi Brian, contact our support at wiht some details, they will help you to set that up.

Brian commented on

For those of you who have used this approach, could you provide code samples. I'm really not following this. I am new to Kentico and I am evaluating their product. The site I am trying to build has a rather complicated layout and I can't quite figure out how to organize the master page and page layouts (I need a page placeholder in the upper left corner and another in the middle right of the page).

Martin Hejtmanek commented on

FYI: Hotfix 5.5.25 contains fix for this as well (also unofficical). In cases when the child template didn't provide the content for all placeholders, the saving of editable text / image might not work properly.

office-css-web commented on

I love it! Thanks!

Andy commented on

Never mind... I just had to configure the inheritance.
I spent hald the day messing with multiple master pages and muliple placeholders ... trying to replicated my VS2008 nested master page appraoch with the portal engine.... Brain was giving up .

Andy commented on

I am evalutating Kentico and am trying to following along with this in my demo 5.5 site. Basically I can't follow.
When you create the Multiple page and then the Child page, can you be clear on exactly which template/layouts these 2 pages are based on? I have tried it 3 or 4 times based on the screenshots, but (possibly because my templates are different than yours) I never get it to turn out.

Michiel commented on

I haven't tried it yet, but it's good to see this is now possible, tahnks!

Jeroen Fürst commented on

Great post Martin! We have been using the multiple placeholders in the portal engine for quite a while now and it works perfectly! :)

roel-ibl-software commented on

I can say we use it extensively, for over a month now, and it works great!