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.
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
Is the "logged in" page a sub page to the other selected page? In that case, both are probably handled as SelectedItemTemplate.
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
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
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
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
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
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?
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
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
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.