PageTree Container.HasChildren is incorrect

Vote:
 

I'm using a PageTree to render a menu, and the templates use different bullets depending on if they have children or not. This works nicely (I have set EvaluateHasChildren=true in PageTree), but not always as it turns out. The site has been in production several months without anyone noticing, but now we have found a few examples of pages where this does not work.

There are situations where Container.HasChildren is false even though it should be true (there are child pages which the visitor can see). According to editors there may also be situations where it's the other way around (HasChildren is true causing the bullet with an arrow to show, even though there are no child pages).

The currently used version is CMS 5 R2 SP1.

#33332
Oct 08, 2009 9:14
Vote:
 

Some more clues...

This seems to happen when the first few child pages (according to sort order as it seems) are not available in the current language. If I browse the Swedish site and the first few children of a menu are available in Swedish only, or Swedish and English, HasChildren will evaluate correctly for the Swedish site. If the first few pages are available in English only HasChildren will evaluate incorrectly for the Swedish site, but correctly for the English site.

It seems that when evaluating HasChildren only the first few children will be inspected, and they may be filtered out because they have the wrong language before counting the pages. So the whole set of children is not used before filtering.

Looking at the PageTemplateContainer.CheckIfHasChildren the prime suspect is the maxRows parameter which is set to 2. I don't know what it does exaclty, but I suspect that it limits the number of results gatherd at a premature state (i.e. before checking the language).

Could this be a bug?

#33335
Oct 08, 2009 10:30
Vote:
 

Looks like a bug to me, I'll report it. But I don't understand why CheckIfHasChildren exists at all since EvaluateHasChildren says that the PageTree control should evaluate children as it builds the tree (and it does pass it to PageTreeControl but that control then don't use it). 

 

 

 

#33347
Oct 08, 2009 14:46
Vote:
 
Agreed. The first thing I did was to set my own HierarchialPageLoader.GetPageCallback to monitor what it actually did when getting the children and saw that it got the correct number of children. I was then very surprised to find that the Container.HasChildren actually did a completely separate check.
#33348
Oct 08, 2009 15:05
Vote:
 

I'm experiencing the exact same thing. Is there a fix for this yet?

/Jakob

#35368
Dec 08, 2009 13:19
Vote:
 

Its fixed and will be part of CMS 6:
Bug #29561: HasChildren in PageTree templates sometimes returns the wrong value on globalized site
Possible workarounds is to make sure the first sub page is available on all languages, or use your own HasChildren logic.

#35369
Edited, Dec 08, 2009 13:35