Redjam
Redjam

Reputation: 534

Wagtailmenus: how to access Page fields from first level menu?

I'm using Wagtailmenus 3.0.2.

The documentation says:

If the template is for rendering the first level of a main or flat menu, then menu_items will be a list of MainMenuItem or FlatMenuItem objects (respectively). In all other cases. it will be a list Page objects.

(https://wagtailmenus.readthedocs.io/en/v3.0/rendering_menus/custom_templates.html)

I'm using a FlatMenu with only one level. I need to access Page fields but it's not rendered in the template.

When I use a multilevel menu, I can access Page fields inside the submenu without problem.

I wonder if there is a way to access Page fields inside the first level menu.

Thanks in advance for your help!

Upvotes: 0

Views: 230

Answers (1)

AYS
AYS

Reputation: 26

You can use item.link_page at top level of menu, for example:

{% for item in menu_items %}
  ... {{ item.link_page.title}} ...

Upvotes: 1

Related Questions