Initiating a MenuList with the current page not the StartPage


Hi everyone - early days for us with EPiServer 5 so excuse the (what should be) fairly obvious question, but we want to start the Page collection source as being children of the current page, not as children of the start page. So...

<OurMenuList>.PageLink = PageReference.StartPage;

works great for the root navigation, but we want our current page (a 1st level sub-navigation) to be the start page - something like (which doesn't work)

<OurMenuList>.PageLink = PageReference.SelfReference;

Any pointers much appreciated!


Mar 26, 2010 14:38

MenuList.PageLink = CurrentPage.PageLink

Or you could set in the aspx: PageLinkProperty="PageLink", then you don't need to databind the pagelist.

Mar 26, 2010 15:26

Thanks for the reply Erik - and yes that makes total sense!

However what I've actually worked out is that we actually don't really want to do what I was suggesting as when we navigate through the site we want the navigation to stay consistent, not changing to sub-sub pages etc... :-)

So, what we really want to be able to do is to get the OpenTopPage from our primary MenuList and use this as a secondary navigation without showing the primary navigation.

I can achieve this currently by creating the primary navigation as a MenuList and then creating the secondary navigation as a PageTree and hiding the primary MenuList using display=none in the CSS.

However this seems a pretty ugly way to do it so has anyone got any good suggestions as the _right_ way to do this?

Many thanks


Edited, Mar 29, 2010 12:36

I think I can answer my own question here :-)

Looks like creating a MenuList object directly in the code means that you can refer to it, without actually having to display it.

Mar 29, 2010 14:55

You still need to set the MenuList property. See the public templates code (master page code-behind) for an example or (I've updated the code after your comment).

Mar 29, 2010 15:08

Cool Frederik - many thanks again :-) Alex

Mar 29, 2010 17:41
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.