Hello,

The module works just fine but I'dd like to have custom fields to be also returned by the module, for example the module menu_item_extras allow to add custom fields to the menu items, and I'd like those fields to be also returned for the menu items.

Is it possible to have this done?

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

KevinBlanco created an issue. See original summary.

fabianderijk’s picture

I think this will be possible. I will see how and when I can add this.

ainarend’s picture

Any ideas on this issue? We need it on two projects, so I am interested in having support for the extra fields added by the menu_item_extras module.

Currently there is a workaround available in here (comment #5):
https://www.drupal.org/project/menu_item_extras/issues/2959787

In that issue there's also a hint that one should use jsonapi instead, but i think currently it's still impossible to use jsonapi without patches either to build a menu, as there are some pretty deep issues that need to be resolved for that.

So any ideas or directions on what one should do to support the fields added by menu_item_extras in this module?

ainarend’s picture

Status: Active » Needs work
StatusFileSize
new4.41 KB
new4.41 KB

Okay, this is a first very simple take at it. It simply adds all menu item extra fields to the output. Correct normalizing and multivalue field support should be added. And some validation with how it works with caching.

Also the configuration for the module should be improved. Menu_item_extras adds fields per menu, then we'd need to allow configuring the output per menu as well. But this seems a good idea in any case, even without supporting menu_item_extras.

This is still very much a WIP, but hopefully it gets the ball rolling

voleger’s picture

That's correct, menu_item_extras introduce altering entity type definition of menu_link_content entity type. That allows enabling field UI functionality for custom (content) menu items. Also, the module provides UI workarounds to correctly render the menu items (that part is not perfect and we have a plans to move that into submodule)

So there no needs to support menu_items_extras. Just keep in mind that menu_link_content entity type eventually will contain custom fields.

voleger’s picture

Also, there is an initiative to remove the bundle key for menu_link_content
#2987537: Custom menu link entity type should not declare "bundle" entity key
so that's mean that field UI UX would be similar to the User entity.

jpschroeder’s picture

Great start @ainarend. In your two projects did you flesh this out any more? We're also struggling to find a solution to getting menu items with fields to output.

ainarend’s picture

Hi, @jpschroeder! Unfortunately I didn't do any further work with the patch.

geoffreyr’s picture

StatusFileSize
new3.59 KB

I've rerolled this patch to work against REST Menu Items 3.0.x.

rcodina’s picture

Patch on #9 works for me.

wrd’s picture

#9 is working for me as well. Very useful.

mofdi’s picture

StatusFileSize
new2.96 KB

#9 is working with text field for exemple, but it does not work well with the reference and revision reference fields, I added a change to retrieve the referenced entity

carlxjs’s picture

StatusFileSize
new3.27 KB

Modify the patch above, makes it can apply in 3.0.2

kunalgautam’s picture

StatusFileSize
new4.12 KB

Modified patch #13 with image uri.

kunalgautam’s picture

StatusFileSize
new4.17 KB

Update the patch for image fields absolute URL.

fabianderijk’s picture

Thanks for all the work, In the last patch (#15) I still see some todo's. Can you this? Is it possible to have this done? And can you do this in an issue fork? This way it's easier for me to check the patch.

vistree’s picture

I tested the patch today - and it is quite nice ;-) What I found as a problem is, that media reference fields (image media) does not render the image style defined in menu item display settings (master - thumbnail - image style).

kbriand’s picture

StatusFileSize
new5.64 KB

Reroll of the #15 patch for the 3.0.3 release.

gangu’s picture

Thanks @kbriand This patch #18 Its working.

amitajgaonkar’s picture

StatusFileSize
new4.39 KB

Pathc #15 did not work for me. Did few change on top of #15.

nishat ahmad’s picture

Path #15 #16 and #18 not working for me

himanshu_jhaloya made their first commit to this issue’s fork.

himanshu_jhaloya’s picture

StatusFileSize
new72.01 KB

#20 patch is not applying

gangu’s picture

I got error after apply #18 patch

LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\rest\ResourceResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (line 154 of /home/genesis/drupal/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).

I did few changes as per refer link below.

https://createdbycocoon.com/knowledge/drupal-logicexception-controller-r...

Its working now.

Regards,
Gangadhara U

codysaylor’s picture

StatusFileSize
new7.43 KB

Thanks for that solution @gangu, applied it on #18 and seems to have fixed it.

batigolix’s picture

Status: Needs work » Needs review
batigolix’s picture

Issue tags: +finalist-sprint
dhruvr’s picture

This patch #18 Its working.

bram.velthoven’s picture

Status: Needs review » Reviewed & tested by the community

Tested patch on comment #25 and checks out, settings to RTBC!

  • 03a7b5cd committed on 3.0.x
    Issue #3039979 by ainarend, kkalashnikov, himanshu_jhaloya,...
batigolix’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for all the hard work @everybody

Status: Fixed » Closed (fixed)

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

vistree’s picture

hi, it seems, that there is still a small outstanding issue: if the menu is translatable and the menu_item_extra fields are translated - always the source language is returnde - and not the translation

dinesh18’s picture

reroll the original patch with 3.0.3