Hi all,

I am using Drupal Drupal core 8.2.6, REST UI 8.x-1.13, Rest menu items 8.x-1.2.

And I could not use the max_depth and min_depth, I have tried both as:

/en/api/menu_items/main?_format=hal_json&max_depth=1
/en/api/menu_items/main?_format=hal_json&min_depth=1

But I cannot see any change.

I guest that it is a bug, but could be that I don't know how to use it properly?

Apart of that I have a question, is posible to get just an item of the menu and print its submenu links?

Comments

dimr created an issue. See original summary.

fabianderijk’s picture

Hi dimr,

I guess this is a bug then. I will take a look at it ASAP.

As far as selecting just 1 item and showing it's children, it is not possible at this moment. But it could be a nice addition. Do you have any idea's on how to select that one item? Based on the menu item ID probably?

breidert’s picture

Attached is a patch that fixes the issue.

I also added caching to the ResourceResponse so the parameters min_depth and max_depth are respected.

breidert’s picture

I noticed that the properties

  • weight
  • expanded
  • enabled

are missing.

breidert’s picture

Attached is an updated patch that adds weight, expande, and enabled.

Also a small improvement to caching. Cache context is only set to url.query_args if minDepth and maxDepth are not 1.

fabianderijk’s picture

Status: Active » Fixed

This issue is fixed in the new 8.x-1.3 release. Thanks for the patch.

Status: Fixed » Closed (fixed)

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