Initiating a MenuList with the current page not the StartPage

Vote:
 

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;
<OurMenuList>.DataBind();

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;
<OurMenuList>.DataBind();

Any pointers much appreciated!

Alex

#38012
Mar 26, 2010 14:38
Vote:
 

MenuList.PageLink = CurrentPage.PageLink

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

#38021
Mar 26, 2010 15:26
Vote:
 

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

Alex

#38075
Edited, Mar 29, 2010 12:36
Vote:
 

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.

http://world.episerver.com/Get-Started/Developing-with-EPiServer-CMS/Getting-Started-Developing-with-EPiServer-CMS-5/Getting-Started-Sub-Menu/

http://www.frederikvig.com/2010/02/adding-different-css-classes-when-using-the-episerver-pagetree/

#38082
Mar 29, 2010 14:55
Vote:
 

You still need to set the MenuList property. See the public templates code (master page code-behind) for an example or http://www.frederikvig.com/2009/08/episerver-web-controls-menulist-and-pagetree/ (I've updated the code after your comment).

#38083
Mar 29, 2010 15:08
Vote:
 

Cool Frederik - many thanks again :-) Alex

#38096
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.