How to add field from internal node to related menu item

Created on 19 April 2022, about 3 years ago
Updated 30 June 2023, about 2 years ago

I need to add an additional field value from internal node entity to rest export. Is this somehow possible by using a hook?
Steps to reproduce:
1. Add field "category" (field_category) to content type basic page.
-> Field category is an select field with 3 values (internal, external, general)
2. Add category external e.g. to basic page "imprint"
3. Link node "imprint" to main navigation
4. Inspecting /api/menu_items/footer?&_format=json I would like to add "category" from internal node to the output

How can I implement this?

💬 Support request
Status

Fixed

Version

2.9

Component

Miscellaneous

Created by

🇩🇪Germany vistree

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇱Netherlands batigolix Utrecht

    Yes, you can alter the output by implementing the hook hook_rest_menu_items_output_alter.

    In that hook you would have to load the nodes that the menu link is referring to, and then fetch the desired data from that node and add it to the endpoint's output.

    See the file for more info rest_menu_items.api.php

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024