How to create "page-dependent" menu

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
7/22/2011 9:34:57 AM
Gravatar
Total Posts 8

How to create "page-dependent" menu

Hello,

I'm new to mojoPortal (and I'm also new to ASP.NET).

I have to build a site with "page-dependent" menu: some menu items should be available only on some pages, independently of the user. What is the right (and easy) way to do it?

As I understand, in Administration Menu the availability of a page (and the corresponding menu item) is defined by the current user's role. Also in the database, in the "mp_Pages" table, I cannot see something like "MenuID" column.

The possibilities I can imagine are: changing the whole "IncludeInMenu" column depending on the current page, or changing current user's role depending on the current page, if that's possible. But none of these "methods" seem good to me... I can imagine, there is a simple and elegant solution to my problem.

Thanks in advance, Pavel

7/25/2011 7:47:29 AM
Gravatar
Total Posts 18439

Re: How to create "page-dependent" menu

Hi,

In mojoPortal the menu is based on the hierarchy of pages so pages can be viewed as equivalent to menu items. So menu items for a page are basically the child pages below that page in the hierarchy.

See Creating Pages and Managing the Site Hierarchy

also you should avoid thinking in terms of forking the code or making changes in the in mojoPortal tables.

Hope that helps,

Joe

7/25/2011 9:37:23 AM
Gravatar
Total Posts 8

Re: How to create "page-dependent" menu

Hi Joe,

Thank you very much for your response! Yes, I understand that in mojoPortal menu items correspond to pages, and the menu item is shown if the corresponding page is included in menu and if it's accessible to the current user. I surely don't want to fork the code and, as I mentioned, I don't like the idea of changing the mojoPortal tables.

What I need is to have different menu items on different pages, where each menu item corresponds to the real page. And I have to do it without user authentication. There should be two main areas of the site, each with its own menu, but also with several interlinks. On the start page the user chooses which of these two areas he wants to access.

The structure should be something like this:

http://mysite.com/home.apx
http://mysite.com/area1/home.apx
http://mysite.com/area1/page1.apx
http://mysite.com/area1/page2.apx
http://mysite.com/area1/page3.apx
...
http://mysite.com/area2/home.apx
http://mysite.com/area2/page1.apx
http://mysite.com/area2/page2.apx
http://mysite.com/area2/page3.apx
...

Pages in area1 have menu with items from area1; pages in area2 have menu with items from area2 and one item from area1. And there is always a link leading back to http://mysite.com/home.aspx.

I first thought about creating multiple sites on the same mojoPortal installation (the main site with the start page only plus two additional sites for each area), but it doesn't seem to be a good idea, because these two areas should share some of the content (for example, http://mysite.com/area1/news.aspx and http://mysite.com/area2/news.aspx provide the same information, only have different menus).

And again, all this should work without user authentication (but also for authenticated users), and with the possibility to link all pages in both areas from outside.

What's the right way to do it?

I have to change the available site, which was created not by me, by adding the second area, and I have to do it before Friday. And I still don't have an idea how...

Thank you in advance and sorry for the long explanation!

Pavel

7/25/2011 9:58:48 AM
Gravatar
Total Posts 18439

Re: How to create "page-dependent" menu

Hi,

First we do not support extra / segments in the friendly urls for reasons discussed here.

If you really want urls like that it would be possible to do it with multiple sites based on folder names and using related sites mode to share users and roles across sites. But my advice is don't try to express the site hierarchy in the url because as mentioned in the article linked above urls should not change but the site hierarchy should be easy to change.

Hope that helps,

Joe

7/25/2011 5:56:22 PM
Gravatar
Total Posts 8

Re: How to create "page-dependent" menu

Hi Joe,

Thank you for your help! I was thinking about using multiple sites based on folder names, but didn't notice this related sites mode, which of course will help, but not completely. As I understand, there is no possibility to share content between multiple sites, right? In my case it's desirable, because part of the content is the same for both areas.

Does that mean that there is absolutely no possibility to easily control which menu items appear on which page? There is my only problem: to have two different menus. That's what I have to do and I cannot change this requirement.

I'm trying to do the following: I defined two roles, area1-users and area2-users. The pages and menu items of area1 are accessible only by area1-users, and the pages and menu items of area2 are accessible only by area2-users. There is also two "dummy" accounts, area1-user and area2-user, which are added to these two roles, correspondingly. Then, there are two user controls, for the pages of each area, containing a script that checks, if the current user is authenticated. If yes, it removes the user from one role and adds him to another role. If the user is not authenticated, it logs him in either as area1-user or area2-user. One of this user controls is added to each page, depending of its area. This way each page either changes the role of the current user, or logs him in and out using one of the two "dummy" accounts.

This is not ready yet. And I don't think this solution is good, but I don't have better idea yet...

Many thanks in advance,

Pavel

 

7/25/2011 9:12:30 PM
Gravatar
Total Posts 2253

Re: How to create "page-dependent" menu

Hi,

I have done something similar with my "extranet" website.

The key is that you need two separate skins each of them set to different pages for their menu. The way we use it is we have public pages that everyone can see and restricted pages that only members of a particular role can see. All of these restricted pages are children of a single page named Team. The first skin is the default site skin and it's menu isn't any different from any other skin. The second skin is applied to the Team page and all of the pages under it. This skin has StartingNodeOffset="1" set on the SiteMenu control so when an allowed user browses to a page using the second skin, the menu changes, only showing them the pages in the "Extranet."

This is all explained in more detail in the Visual Partitioning document.

HTH,
Joe D.

7/27/2011 5:32:43 PM
Gravatar
Total Posts 8

Re: How to create "page-dependent" menu

Thank you Joe (Davis) for your suggestion! It works now exactly as desired. And it's a simple and elegant solution, not comparable to the ones I was thinking about. And thank you Joe (Audette) for creating this system and answering to my questions! I just started to use it on my new job, and I'm sure I'll be back here soon.

Best regards,
Pavel Borodin

You must sign in to post in the forums. This thread is closed to new posts.