2

Using search_api (and search_api_solr) i have a view that shows nodes for (in this case) Organisations in a search_view. That works very nicely.

Now, I would like to show a list of taxonomy terms that are associated with the nodes in the result set. These terms should be in a list of their own, and I need to be able to access the fields on these terms. (In this case, Districts is the Vocabulary, and each organisation can be active in 1 or more Districts. I need to get to the Geofield on these Districts so I can create an Openlayers map).

When I add a Relationship to the search_view to the District field, I see the message

"Note: This is a multi-valued relationship, which is currently not supported. Only the first related entity will be shown."

So, that is not the way (yet).

I am stuck thinking about a workaround for this. Any pointer would be much appreciated.

2
  • You could maybe export the view and thus add your own code to grab the data you need from related values which views lets you call?
    – tecjam
    Dec 9, 2011 at 11:48
  • can you make another view and then use drupal.org/project/views_field_view to get the multiple values pulled in? May 31, 2016 at 6:54

1 Answer 1

0

This may have drawbacks but I had a situation where i wanted to show the multiple tags that related to content that i had indexed.

Having looked through https://www.drupal.org/node/1378656 i opted to try by using https://www.drupal.org/project/views_field_view

Happy to report it worked

Here is the recipe:

  • create a new View based on Content for types involved and set just the relevant 'term' field as the display (you don't need to create any views displays).

  • set Contextual filter to nid with 'provided default value = raw value from url' (outcome should be if you enter the nid you should see relevant tags in preview). Save

  • install/enable https://www.drupal.org/project/views_field_view

  • over in the view that is rendering the search results (searchapi)

  • made sure you have Indexed Content: Node ID field already in your Fields, and set to not display

  • add a new field of type Global: View

  • in the 'view settings' of this field, find the view you made above, set the right display or use Master if you didn't make any (because you didn't need to),

  • in Contextual Filter, check your Replacement Patterns where you should have [%nid] == Indexed Content: Node ID (rendered), and enter [%nid]

  • save and I hope you get to smile like i just did.

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.