KnpLabs / KnpLabs/KnpMenu

Render menu containing only siblings of active menu item

Open
#153 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1.4k
Forks
189
PR merge metrics
No merged PRs in 30d

Description

I'm curious, is there a way to render a partial menu containing siblings (and maybe children) of the current menu item?

Given a menu tree:

```
Items
--> Bat
--> Ball
------> Large Ball
------> Medium Ball
------> Small Ball
--> Bottle
```

If the user is on the `Large Ball` page, I'd like to be able to render all siblings. In my real case, they would be rendered as tabs.
#84 may be the same thing, but it seems like that use case is actually rendering all the ancestors as well.

It seems I can do this:

```
{{ knp_menu_render(['AcmeDemoBundle:Builder:mainMenu', 'Items', 'Ball']) }}
```

But that would require that I know the name of the current menu item. If I can get that in twig somehow, I guess that would be fine and I could just fill it in there, but ideally there'd be some baked in functionality to support rendering sub-trees.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by examining the `knp_menu_render` entry point and compare this request with issue #84. Define how the renderer should identify the active item and whether its siblings and children are included; done means a menu can render the requested subtree for the `Large Ball` example without requiring the caller to know the current item name.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.