Problem with SelectedItemTemplate with multiple menus

Vote:
 

Hi:

I have a problem with SelectedItemTemplate in the Page Tree. I have two menus on the website:

-One that displays to anonymous users

- One for logged users.

When logged in, both menus are displayed.

The problem comes when logged in. The Homepage menu item is instantiated by SelectedItemTemplate in many of the logged in pages.

E.g.

If I am at loggedPage1.aspx. The menu item for this page (in the logged user menu) is instantiated by SelectedItemTemplate. And the HomePage menu item in the anonymous menu is also instantiated by the SelectedItemTemplate.


The weird thing is that this does not happen with all the pages in the logged in area, just with some of them.

Is this a known bug or what could be the problem?

Many thanks.

 

#50285
Apr 21, 2011 14:30
Vote:
 

Have you tried setting the permissions on the pages shown in the menu using the virtual roles for logged in users, specifically the "Authenticated" role? The EPiServer controls should respect these and only show the appropriate menu items depending on the users logged in state.

#50293
Apr 26, 2011 15:20
Vote:
 

Hi David:

Thanks for your reply. The problem is not hidding one menu when logged in. The problem is that I get an two menu items marked as selected items (one in the logged in menu and one in the normal menu).

There should be just a single menu item marked as the selected/current item (Each link points to a different page).

I don't understand why two mene items in different menus are marked as selected on the same page.

 

Any ideas?

Many thanks

#50317
Edited, Apr 27, 2011 11:20
Vote:
 

Can you post some code examples in so I can take a look?

#50329
Apr 27, 2011 16:07
Vote:
 

Is the "logged in" page a sub page to the other selected page? In that case, both are probably handled as SelectedItemTemplate.

#50343
Apr 28, 2011 10:51
Vote:
 

I think I know what is the problem. One menu links to EPiServer pages, and the other menu links to some Custom Pages (Not in EPi).

When the control tries to find the current page and since the page is not an EPiServer page it gets/assumes that it is the start page.

I found out about it when checking some other changes that I made, I had link that changed when navigating in the Homepage, but just find out that it also changes when navitaging in Non EPiServer pages.

I think I need to check first if the page is an EpiServer page, any idea of how can I check if the current page is EPiServer or not?

 

Many thanks

#50348
Edited, Apr 28, 2011 13:42
Vote:
 

The easiest way to work out if a page is EPiServer or not is to use the URL rewrite provider, if it does not resolve then you know you are not using an EPiServer page (obviously its easy to look for pages ending with .aspx!):

EPiServer.Global.UrlRewriteProvider.ConvertToInternal(new UrlBuilder("/Your/URL.aspx"))

The return code (bool) will let you know if the page converted to an internal URL.

David

#50351
Apr 28, 2011 16:37
Vote:
 

Thanks for the reply David. I tried using the URL Rewrite Provider but it always returns false, no matter which page I am in. Here is my code.

var url = HttpContext.Current.Request.Url.LocalPath;
EPiServer.Global.UrlRewriteProvider.ConvertToInternal(new UrlBuilder(url));

    

Any idea what can be wrong?

Many thanks

#50353
Edited, Apr 28, 2011 17:52
Vote:
 

Hello Carlos

If you use the following code then you can work out if the URL has been converted to internal (i.e. its an EPiServer URL) or not:

var url = HttpContext.Current.Request.RawUrl;
bool convertedToInternal = EPiServer.Global.UrlRewriteProvider.ConvertToInternal(new UrlBuilder(url));

    

David

#50354
Apr 28, 2011 18:01
Vote:
 

Wtih RawUrl works fine except for the start page. When in the start page the boolean value is false. Any idea why is not working with the start page? Thanks

#50355
Apr 28, 2011 18:40
Vote:
 

I just tried it on my local sandbox (CMS 6 R2) and all worked OK (where rawUrl == "/")? What does the RawURL look like on your start page?

#50357
Apr 28, 2011 18:50
Vote:
 

The RAWULR for my start page is "/default.aspx?"

I tried manually editing the value to "/" in debug mode and then it works fine.

 

Cheers

#50367
Edited, Apr 29, 2011 8:39
Vote:
 

I found another solution. Each page type is of a different class so I just check if they belong to that class.

if (Page is PageClass1) { ... }

   
And it seems to be working fine. Thanks for the advice

Cheers

#50368
Edited, Apr 29, 2011 9:15
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.