Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have the Profile 2 module where a user selects a zip code (which is an entity reference to the content type ZipCode)

The ZipCode content type has an entity reference to a Region content type.

Finally, there is a content type called Schools which has an entity reference to the ZipCode content type.

I would like to display all schools that match the region of the logged in user. Logically this means finding the user's region, and then all schools with the same region, through the zip code...

I can't for the life of me figure out how to do this. Any help would be appreciated.

share|improve this question

1 Answer 1

The easiest way to do this is using views. You will create a view for the content type "School" and you will add all the fields you want to display on your list, then you will add 2 more things:

  1. A reference to the entity that is common between the "School" content type and the "ZipCode" content type. If there is no connection between the two you will then also need to add a reference to the "Region" content type and then to the "ZipContent" type.

  2. Add an argument or contextual filter where you will use the user ID of the login user the limit the nodes of the content type "School" been display.

Note: I have sometimes achive the same result by creating a views for users and referencing the content types and adding the desired fields.

Here is a video about views arguments: http://mustardseedmedia.com/podcast/episode39

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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