Loudenvier
Loudenvier

Reputation: 8804

How to have different secondary menus for groups of pages in Orchard CMS?

I've got to implement navigation using a main menu (easy) but then each menu will lead to a group of pages that have another "submenu" which I've implemented as a menu widget in the before content area.

The main navigation is something like this:

Home | First Group | Some page | Another page | Second Group | Yet another page

When the user clicks Home, Some page, Yet another page, it is taken directly to that page.

If the user clicks any of the "groups" it is taken to the "default page" for that group, and a submenu which is implemented as a menu widget is shown in the before content area. The first group can have 5 pages

Page 1.1 | Page 1.2 | Page 1.3 | Page 1.4 | etc.

The Second Group will have another set of pages.

I've naively set the path properties for the subpages so that they share a common path:

/group-1/page-1-1 /group-1/page-1-2 /group-2/page-1-3 etc.

/group-2/page-2-1 /group-2/page-3-1 etc.

I was expecting to use the Match Path to hide one widget menu in under one path or the other. But the problem is that I can't target a specific Menu or Widget, only content types in general, etc. I can't do something like this:

<Match Path="/group-1/*" ContentType="Widget SOME WAY TO TARGET A SPECIFIC WIDGET!!!">
     <!-- SEND THE NEEDED PARTS TO OBLIVION SO THAT ONLY THE CORRECT MENU SHOWS HERE --!>
    <Place Parts_Common_Body="-" />
</Match>

I believe that it would be much better to use a layer rule to target a specific path, but I just can't match a layer rule to something like url("/group-1/*"), so that's why I've tried to use the placement info which seems to be the wrong tool.

Is there a way I can extend the layer rules to work with regular expressions, for example? This way I can create really powerful layers and just layout my widgets on the proper layers.

In summary what I want is to have different submenus for different sections of the site. I'm just kind of lost on how to accomplish that, but layer rule seem to be the right tool, only if I could manage to use a little more powerful matching syntax.

Upvotes: 0

Views: 738

Answers (1)

Loudenvier
Loudenvier

Reputation: 8804

I think I'm kind of blind!!!

Straight from the docs:

url("<url path>")
True if the current URL matches the specified path. If you add an asterisk (*) to the end of the path, all pages found in subfolders under that path will evaluate to true (for example, url("~/home*")).

So adding this rule was enough to create a layer for an entire section of the site:

url("~/group-1*")

I'm almost ashamed of myself...

Upvotes: 1

Related Questions