Suppose that I have a nested menu structure:
- Colours
- Red
- Red
- Scarlet
- Maroon
- Blue
- Blue
- Navy
- Ultramarine
- Red
- People
- A
- Alice
- Alison
- B
- Bob
- Bill
- A
On each page, I would like to render a partial view of the menu.
- Parts of the menu not on the current path, should be excluded from the output.
- Note: not “included, then hidden with Javascript”. I mean never included in the output HTML at all. Reason: The full menu contains thousands of items.
- The parent(s) of the current page, should be highlighted. (i.e. bold.)
Example: on the page for “Maroon”, the menu should render as:
-
Colours
-
Red
- Red
- Scarlet
- Maroon
- Blue
-
Red
- People
How can I accomplish this?
The documentation for menus mentions some functions IsMenuCurrent
and HasMenuCurrent
, which were implemented (#367) but not documented (#1393). I’m willing to submit a PR documenting these, if someone can help me understand how they work.
The thread Confusion regarding proper use of menus also refers.
Edit: See also.