0

I have an article and food content types. I use location module fields in both content types. So for example, when I write an article about restaurants in New York, I choose article's location as country: US, state: NY and city:New York. Now, I want to be able to show related food items in view with same country, state and city. Now, how do I display food items matching with article's location.

1 Answer 1

0

Sibling items are usually displayed with the help of two Relationships and one Contextual filter.

Create Food item Views.

You first add the Relationship for your Location field, it introduces info about the Location.

Then you add the reverse Relationship to the first one, it will use the first Relationship. The second one points back to the content that is using that Location field.

Add the Contextual filter for Node ID and make it use the second Relationship. Set it the usual way, default value and ID from URL, validate against Article Content type.

I haven't tried this with the Location field but the logic should be the same.

4
  • hi prkos! The problem with the location module, there are no fields to relate, as locations "attached" to nodes
    – jamie
    May 24, 2019 at 11:23
  • There seems to be the CCK field that is using the Fields API. But the other field type also seems exposed to Views. Have you taken this to the module Issue queue? Maybe these shed some light in your case:location_cck views relation for D7, location CCK and views.
    – prkos
    May 24, 2019 at 14:09
  • I changed the field to CCK now, thank you! On the next step, what will be the reverse relationship item?
    – jamie
    May 24, 2019 at 15:33
  • It's difficult to say flying blind. Can you search for "location" when adding Relationships, to reduce the possibilities? You should then be able to recognize by the wording that it points back to content using that location.
    – prkos
    May 24, 2019 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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