# menu\_expand

Source: https://zotonic.com/docs/2274/menu_expand

URI: https://zotonic.com/id/2274

Language: en



Takes a menu, or a menu resource id, and adds all `haspart` objects connected to the menu ids.

With this filter it is possible to add a collection to the menu and have the pages in the collection automatically added to the menu.

Example:

```django
{% with m.rsc.main_menu.menu|menu_expand as menu %}
    {% if menu %}
        {% with id|menu_trail:menu as trail %}
        <ul>
            {% for item in menu %}
                <li {% if item.id|member:trail %}class="active"{% endif %}>
                    <a href="{{ item.id.page_url }}">{{ item.id.title }}</a>
                </li>
            {% endfor %}
        </ul>
        {% endwith %}
    {% endif %}
{% endwith %}
```

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2274?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/2274?language=en>)
