I'm really struggling to get my head around how to replicate the basic functionality of an existing site I'm trying to port over to Drupal.

Basically the main pages are locations. These are within regions that are within countries that are within continents:
continent->country->region->location (each level has associated descriptions)

The original site just has a DB with foreign keys in the lower level referencing the ID of the parent - e.g. country will have a continent field referencing the ID of the relevant continent.

I've had some success importing the data and setting up entity references to reflect the above structure. So I now have a country content type with a continent entity reference field pointing to the relevant continent.

What I would like to be able to do is create a view for each continent which lists all the countries below it. And the same for countries and regions etc. These would also be dynamically accessible via the URL, e.g. mysite.com/europe/france/paris

Any suggestions on what I need to do would be hugely appreciated.

Thanks,
Chris

Comments

WorldFallz’s picture

One way to do it is to simply create a listing of all countries-- the entityereference field will display the title of the referenced field. Then just group by the entityreference field. You can also add a relationship for the referenced entity which you can use to access any of the other fields besides the title.

surfgatinho’s picture

Thanks for the help.

I've now got to the point where I can get all the countries within a continent by sending the node id of the continent to the view as an argument in the URL.
I guess that's a start. However, I really need to be able to access the referenced entity by one of the other fields such as 'name'. Can this be done using entity reference?

WorldFallz’s picture

You can also add a relationship for the referenced entity which you can use to access any of the other fields besides the title.

;-)

surfgatinho’s picture

Thanks. Yep, good advice.

Didn't understand what you meant until I'd virtually tripped over it myself.

WorldFallz’s picture

no worries... it's easy enough to miss in the million views options, lol.