0

I have a "stations" and "railways" node types and a custom "notification" entity type. In "railways" node type I have an entity reference field ("field_stations") where I can select "stations" nodes which is good. In "notification" entity type I have an entity reference field where I can select related stations. (entity reference to "stations" nodes) I would like to create a view to list "stations" nodes with grouping and sorting. I would like to group them by "railways" and sort them by delta ("field_stations").

I tried it but I could not get the right order and get a lot of duplications. I have tried views_order_by_delta module as well with no luck.

Do you have any recommendations?

0

I think you're overcomplicating things here. From my reading, you really should be creating your view to:

Show content of type: Railway

This will be your "grouping". You don't want to using the Views grouping option here - that option is more useful when you want to group the result content by a field on each result, i.e. if your stations node type had a reference to Railways.

Fields to Display: Title, field_stations (or, preferable imo, configure a view mode for the Railway node that displays the fields you want to show).

Since we have a view of Railways, your results are naturally "grouped" by Railway. If you just display the stations field from the railway, you'll get the stations listed in the order on the field (its delta).

(optional) Contextual Filter: field_stations

I'm not sure if you actually need this from your description. You can configure a contextual filter for the field_stations field to allow you to show only the Railways (and their stations) if a Railway references a station you pass as an argument.

1
  • Yes, but this gives me the railway ids not the stations ids. Maybe I composed it poorly. "In "notification" entity type I have an entity reference field where I can select related stations. (entity reference to "stations" nodes)" <--- I would like to use that view here as "entity browser". – asrob Jan 27 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.