1

Hi Drupalites I need some help.

1.I was using relationship to output authors personal info associated with a piece of content which i did successfully. so i was trying something else but i didnt succeed.

I created a content type called State-Capital which has a list of of States and their respective capitals and I created another Content type called Misc Project which had different project details like Cost,Project Approve and State.Now i was trying to link the state field to output the capital associated with the respective state in Misc Project content type but i cudnt.The field name for States in both content type are same.Pls help.

  1. I am trying to learn panels so wanted to know if there is any link or material for the same
  • Is state field (in Misc Project) a node-reference field to State-Capital nodes? – Ranjan Jun 15 '14 at 14:36
  • Well field names are same but i idnt use the node referne method initially.Now i hav tried using the node reference logic .I have added a field which is a node reference linking to the State-Capital node.Tell me how to proceed after that – Jasjyot Jun 15 '14 at 18:31
0

Ranjan is correct, you should add a node reference field to the Project content type so it can reference a State-Capital

In order to display any info about the state on the Project page you can use the Views 3 and Reference modules.

For this example let's say the node reference is labeled "Project Location", and the State Capital is Austin, Texas.

Here are some steps you can follow:

1) Create a View

-- Create a new view block that displays State-Capital type nodes.

2) Add a Relationship to the view

-- Add a Relationship: Content: Project Location. This will allow you access to the fields of the Projects that reference Austin, Texas.

-- Give the relationship an identifier. Let's say related_project.

-- Save the relationship.

3) Add a Contextual Filter to the view

-- Add a Contextual Filter: Content: Nid.

-- Edit the contextual filter.

-- Set the Relationship in the contextual filter to related_project.

-- Look for WHEN THE FILTER VALUE IS NOT IN THE URL.

-- Set it to Provide default value -> Content ID from URL. This will get the nid of your Project.

-- Save the Contextual Filter.

-- Add in your fields. (Title at least)

4) Test it

To test in the preview, input the nid of your Project example as a contextual filter in Preview with contextual filters:

Save your view!

5) Enable the block in your node pages

After the view is complete, configure the new block to display in content type Projects.

I hope this helps.

Updated: 2014/06/18

  • updated the instructions. – Japo Domingo Jun 18 '14 at 7:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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