Abstract:
Drupal views should provide flexible functionality for listing different types of entities data and connecting all their relations. The menu system currently seems to be hardly separated from this functionality ("something very different" ;)).
This seems strange and leads to flexibility problems when solving (quite common) tasks like listing up all child nodes of the current node (node hierarchy). This is for example typically the case on overview pages in the menu tree (which shell show the same children hierarchy as the menu itself).
So I'd suggest to add better menu relations for Drupal 8 views like modules like https://www.drupal.org/project/menu_node and https://www.drupal.org/project/menu_node_views did before using workarounds.
The reason why I see this in core is, that both components (and especially the menu) is part of core and from my point of view this is a missing connection / functionality between menu and views.
Problem:
There is no proper D8 views integration for menu and node (or perhaps even other entities) to use these relations in views.
Context:
Building views which show the subpages of the currents node menu entry for example is only possible writing special custom code or module. Views is not really helpful here and if it is, then it's not user friendly.
Proposed solution:
Extend the menu_link_content (and perhaps node) modules for a better menu_link views relationship integration to provide (contextual) filters for menu_link item parents, menu item id's, menu item referenced nodes, etc.
The views integrations should provide similar functionality of what Taxonomy Terms already provide, as much as possible, for example
- Parent / Child & Depth handling (also allow relating items assigned to children menu items)
- Expose all menu item properties e.g. allow to sort by weight
- ...
References:
Drupal 7 solutions / "workarounds" (if I may call it so because of the additional tables tracking the relationships).
https://www.drupal.org/project/menu_node
https://www.drupal.org/project/menu_node_views
Drupal 8+:
https://www.drupal.org/project/menu_entity_index
https://www.drupal.org/project/views_menu_children_filter
Thank you all very very much for your great D8 work!
It would be really really nice to discuss an integration like this. I think Drupal is lacking this since D6.
Comments
Comment #2
AnybodyComment #3
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedThis is an extremely common requirement on our sites. We often end up needing to use methods which don't feel "right," when it seems like showing a node's menu children in a view should be functionality available without jumping through any hoops.
Comment #5
awasson CreditAttribution: awasson commentedYes, I'd agree this is a fairly common feature in the sites I build. I often have main index page views that display teaser information for staff members or company officers, products, etc... that I build in a view. Each views-row contains a link to the node.
If the node, menu-item weight was available within the view, we could sort the view by menu weight.
It seems like a pretty simple concept.
Comment #6
contiveros CreditAttribution: contiveros commentedThis. This right here. Beating myself over my head right now trying to get menu items in views.
Comment #7
John Pitcairn CreditAttribution: John Pitcairn commentedTake a look at the menu_entity_index module.
Comment #8
AnybodyThank you very much for the hint! That's at least a very good starting point.
Comment #9
bmcclure CreditAttribution: bmcclure as a volunteer and at Top Floor commentedThat module looks pretty great! I was unaware of it until now.
I maintain the D8 version of a module with a similar (but simpler) goal: https://www.drupal.org/project/views_menu_children_filter
The primary difference being Views Menu Children Filter is solely for Views filtering, and it doesn't add additional indexes.
Now that I know menu_entity_index exists, I'm curious to try it on a project--it looks like perhaps a better all-around solution.
Comment #12
AaronMcHaleI'd be keen for this to move forward, @bmcclure would you be interested in writing a patch that addresses this based on the code in your views_menu_children_filter module? Alternatively I might have some time in the future to write a patch but I'm not sure at this point if I will.
Thanks
Comment #14
AnybodyI agree with #12 that @bmcclure's module might be a good step for core integration.
menu_entity_index on the other hand uses duplication and an own index which isn't a good way for core I think. This should be solved on the existing data structures.
Views definitely needs support for menu item relationships.
Comment #15
AnybodySuggested merge with #2777749: Add menu_link_content support into views
Comment #16
andypostSurely it is duplicate of #2777749: Add menu_link_content support into views
And the pointed issue already has some patches to review
Comment #17
AnybodyComment #18
Anybody