Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This questions has some similarities with How to display list of nodes that share the same Parent taxonomy term as current node, but I've not managed to figure out how I can get to what I need to do given the answers there.

A have a set of nodes that are associated via term reference with a taxonomy, that is two levels deep. I'll call the parent level area and the child level task.

This is a migration from another website that has pages for publications associated with each area but in my current data structure I only associate the publication nodes with the tasks (children of the areas). The areas each have a legacy_area_id field populated with the area id that was used in the url on the old site.

What I want to do now is create a view that will listen on pub/by/area/% and take a legacy area id as a contextual filter, and show a list of all nodes associated with a child of the taxonomy term that has that value in its legacy id field.

An example:The model

With a data setup like this, a request to /pub/by/area/1

Should return a listing containing Nodes 1, 3, and 4


One option would be to go back and change my migration to associate the publications with areas too, but that seems likely to make the task of moving tasks between areas later quite a bit more complicated.

Another option would be to add the legacy area id to the tasks as well, but that provides similar challenges.

In reality, my end goal is to redirect these pub/by/area/# requests to a different view with the area name in the url similarly to what I've done for other old addresses in How to redirect based on matching a node field?. So really I suppose all the view really needs to give me is the data required to redirect to another view. I'll keep working on this, but help would be appreciated.

share|improve this question
    
a request to /pub/by/area/1 Should return a listing containing Nodes 1, 3, and 4 What do nodes 1, 3 and 4 have in common? Same legacy id? – No Sssweat 2 hours ago
    
Nodes 1,3 and 4 all are associates with tasks that are children of Area 1 which has legacy id 1 – UltraBob 2 hours ago
    
I only associate the publication nodes with the tasks so in your nodes you have a taxonomy reference field and in there you put task and not area, correct? – No Sssweat 2 hours ago
    
That's right. In reality they are all in the Area taxonomy, so what I'm doing is only selecting child terms – UltraBob 1 hour ago

I think I got it, but I couldn't have gotten to it without the other answers on there. I created a page and added two relationships to it:

Content: Taxonomy terms on node (Identifier term) (term) Taxonomy term: Parent term (Identifier Area)

and a contextual filter:

(Area) Taxonomy term: Legacy Area ID

I still have some testing to do to make sure it is grabbing the right things, but so far it seems to be working correctly.

share
    
Interesting, looks like you found another way to do it without using Views Field View, awesome! – No Sssweat 1 hour ago

visabhishek answer gave me an idea.

Create a tax term page view:

enter image description here

  • Add Legacy ID as your contextual filter
  • In FIELDS add term ID (so you will get the term ID of Area 1. You can hide it using exclude from display.)

Then using the Views Field View module

This module allows you to embed a view as a field in a view.

  • Add the view from visabhishek answer as a field. For Contextual filter you can pass the term ID as a token (using replacement patterns)

Problem solved :)

share|improve this answer
    
I'm not seeing how I can get the term id of area 1 from a term relationship that will give me some sub term of area 1? – UltraBob 1 hour ago
    
@UltraBob sorry, that's what happens when I go off memory and don't test things. Updated the answer. – No Sssweat 1 hour ago

Just try once following points

  • Go to admin/structure/views, find the view named Taxonomy term, and enable it
  • Go to admin/structure/views/view/taxonomy_term/edit or Clone this view and create new view with different path
  • Click Advanced (on the right)
  • Click Content: Has taxonomy term ID (with depth)
  • Select a Depth of 1 or more (how much depth term nodes you want)
  • Save all your changes

Hope it will help you...

:)

share|improve this answer
    
Sorry, but this does not help. He wants to use the Legacy ID and not term ID as contextual filter. – No Sssweat 2 hours ago

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.