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?
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | 3039979-support-menu-items-extra-modified-reroll.patch | 3.65 KB | dinesh18 |
| #25 | 3039979-menu-items-extras-19.patch | 7.43 KB | codysaylor |
| #23 | patch-applied.png | 72.01 KB | himanshu_jhaloya |
| #20 | 3039979-menu-items-extras-16.patch | 4.39 KB | amitajgaonkar |
| #18 | 3039979-menu-items-extras-18.patch | 5.64 KB | kbriand |
Issue fork rest_menu_items-3039979
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
Comment #2
fabianderijkI think this will be possible. I will see how and when I can add this.
Comment #3
ainarend commentedAny 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?
Comment #4
ainarend commentedOkay, 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
Comment #5
volegerThat's correct,
menu_item_extrasintroduce altering entity type definition ofmenu_link_contententity 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 thatmenu_link_contententity type eventually will contain custom fields.Comment #6
volegerAlso, 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.
Comment #7
jpschroeder commentedGreat 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.
Comment #8
ainarend commentedHi, @jpschroeder! Unfortunately I didn't do any further work with the patch.
Comment #9
geoffreyr commentedI've rerolled this patch to work against REST Menu Items 3.0.x.
Comment #10
rcodinaPatch on #9 works for me.
Comment #11
wrd commented#9 is working for me as well. Very useful.
Comment #12
mofdi commented#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
Comment #13
carlxjs commentedModify the patch above, makes it can apply in 3.0.2
Comment #14
kunalgautam commentedModified patch #13 with image uri.
Comment #15
kunalgautam commentedUpdate the patch for image fields absolute URL.
Comment #16
fabianderijkThanks 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.
Comment #17
vistree commentedI 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).
Comment #18
kbriand commentedReroll of the #15 patch for the 3.0.3 release.
Comment #19
gangu commentedThanks @kbriand This patch #18 Its working.
Comment #20
amitajgaonkar commentedPathc #15 did not work for me. Did few change on top of #15.
Comment #21
nishat ahmad commentedPath #15 #16 and #18 not working for me
Comment #23
himanshu_jhaloya commented#20 patch is not applying
Comment #24
gangu commentedI 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
Comment #25
codysaylor commentedThanks for that solution @gangu, applied it on #18 and seems to have fixed it.
Comment #26
batigolixComment #27
batigolixComment #28
dhruvr commentedThis patch #18 Its working.
Comment #29
bram.velthoven commentedTested patch on comment #25 and checks out, settings to RTBC!
Comment #31
batigolixThanks for all the hard work @everybody
Comment #33
vistree commentedhi, 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
Comment #34
dinesh18 commentedreroll the original patch with 3.0.3