- Issue created by @robbm
- Status changed to Postponed: needs info
over 1 year ago 2:32pm 20 September 2023 - 🇬🇪Georgia maximkashuba Batumi
robbm,
Can't reproduce the bug with Menu Entity Index module (sorting with the module views relations to menu items).
The results for the entity entityreference filter in a view are the same as for origin/source entity reference view and sorted in the same order.
- 🇬🇧United Kingdom robbm
Thanks for investigating. I thought I'd found that it was any relationship, but perhaps it was the inclusion of views_tree…
I'll try to put together the simplest set of steps to reproduce the issue repeatedly.
- Status changed to Active
about 1 year ago 6:16pm 25 September 2023 - 🇬🇧United Kingdom robbm
Steps to reproduce:
mkdir EntityReferenceFilterTestProject
composer create-project "drupal/recommended-project:~9" EntityReferenceFilterTestProject/repo
cd EntityReferenceFilterTestProject/repo
sed -i 's/"stable"/"dev"/' composer.json # Or for macOS: sed -i '' 's/"stable"/"dev"/' composer.json
composer require drupal/entityreference_filter drupal/menu_entity_index drupal/views_tree
- Install Drupal…
- Enable modules: Menu Entity Index, Views Reference Filter, Views Tree.
- Create Basic pages with titles as follows – adding each to the Main navigation menu:
- Cats (probably nid 1)
- Dogs (probably nid 2)
- Snails (probably nid 3)
- Sphinx (probably nid 4)
- Persian (probably nid 5)
- Moggy (probably nid 6)
- Husky (probably nid 7)
- Chow Chow (probably nid 8)
- Akita (probably nid 9)
- Mutt (probably nid 10)
- Arrange in Main navigation menu as follows:
- Home
- Cats
- Persian
- Sphinx
- Moggy
- Dogs
- Akita
- Chow Chow
- Husky
- Mutt
- Snails
- Configure Menu Entity Index to track Main navigation and Content.
- Create view of Content, e.g. "Classification":
- Change Pager to Display all items.
- Add Relationship to Menu link ID, with an Administrative title of "Menu link". Require this relationship.
- Add Relationship to Parent menu link ID, with an Administrative title of "Parent link". Do not require this relationship.
- Add Relationship to Content (Menu Entity Index), with an Administrative title of "Parent node". Use relationship "Parent link". Do not require this relationship.
- Add field for ID (Content) with no relationship. Move this to the top of the fields list.
- Add field for Weight (Custom menu link) with a relationship to Menu link.
- Add fields for ID (Content) and Title (Content) – each with a relationship to Parent node.
- Add field for Weight (Custom menu link) with a relationship to Parent link.
- Add Entity Reference display.
- Change Format to TreeHelper (Adjacency model), setting:
- Search fields to Content: Title.
- Main field to (first) Content: ID.
- Parent field to (second) Content: ID.
- Remove sort criteria.
- Add sort criteria:
- Weight with a relationship to Menu link.
- Weight with a relationship to Parent link.
Note that the sort order in the preview now echoes the menu order. - Exclude all fields apart from Content: Title.
- Add Reference, Content field to Basic pages, e.g. "Compatible":
- Limit to a single value.
- Select the view created above for the Reference method.
- Change the field from Autocomplete to Select list for the Form display.
- Create or edit a Basic page.
Note that sort order in the drop-down for the field created above is not the same as previously seen in the preview, i.e. it no longer echoes the menu order. (Not exactly the original issue, but closely related.) - Create view of Content, e.g. "Animals":
- Change Pager to Display all items.
- Add Page display with a path, e.g. "animals".
- Add entity reference filter for the field created above, e.g. "Content: Compatible (field_compatible) (entityreference filter)", and expose it.
Note that sort order in the drop-down for the filter is not the same as previously seen in the preview, i.e. it no longer echoes the menu order.
- 🇬🇧United Kingdom robbm
In hindsight, the drop-down might be respecting the sort criteria, just not the Views Tree "grouping". Will double check and come back…