We're using the PageTree control to render a sub-menu.
It supports multiple levels, and uses the ItemTemplate, SelectedItemTemplate and SelectedExpandedItemTemplate.
The problem we've come across lies within the control incorrectly using the SelectedExpandedItemTemplate, it doesn't seem to take the PageVisibleInMenu property into account.
If a page is selected, has children, but all of them are hidden from display, the SelectedItemTemplate should used.
I've been diggin' around in the reflector to try and manipulate the control to my liking, but I didn't really succeed, and it seemed like alot of work for such a simple thing.
Is there an easy (yet effective) way to solve this?
If my memory serves me right, there was a kind-of-bug in CMS 5 (R2 SP2 was my version I think) were the PageTree would use it's own method evaluate if there are child pages where it would only get two child pages. If those were then not visible in menu or not visible to the user based on access rights, the node might falsely be evaluated as not having any children to display. Does this sound familiar?
I can't find the email I got when reporting this and I can't find anything in the buglist because it's not working...
After reading your post more carefully I realize it's not the same issue, it would cause things to work the other way around. But the issue looks like it's similar. Look at the IsExpanded method of PageTreeData (superclass of PageTree), it doesn't care about access rights or visible in menu. You could probably subclass PageTree and override this behaviour to perform a FilterForVisitor on the child pages before counting them.
So what you are saying is, if your page has children, say five of them, and the first two where hidden, the SelectedItemTemplate would be used instead of the SelectedExpandedItemTemplate?If I understand you correctly, then your reply sounds more like a reversed effect.
The easiest way that I can think of to solve this, is creating a method that takes a PageData object, check it's child-count is after a FilterCompareTo(PageVisibleInMenu.. and render the appropriate class based on the that.Easy, and it does the job.
Does anyone have a better solution to the problem?