0

I have two content types:

  • Course
  • Subject

The Course nodes have a field reference field which references a Subject node.

In the Course node display, I want to have access to the variables from the corresponding Subject node. I've set the field to render as 'rendered node', but I need to rearrange the fields from both nodes to construct a tabbed interface out of all of the fields available.

What's the best way to proceed?

2 Answers 2

1

Using a template, as suggested above, you force your drupal to use subject-node.tpl.php to display "subject" nodes, no? To display fields or data from the referenced node you could create a view that returns fields and everything you want, setting a "nid" contextual filter. So, in your "course template" you have to include the view, in this way:

print views_embed_view('view_name', 'views_display', $node->nid);

You can also use Context module to display this view.

1
  • Thank you. I this is exactly what I want. Yes you were right, I don't want to create a subject.tpl file, as I'm going to construct a complex tabbed page out of a mixture of variables. Thanks :) Jul 13, 2012 at 13:06
1

Hi you can use theme_render_template() function like below.


$subject_node_object = node_load('node/' . $node_id_from_ref_filed);// Pass your node ref here.
// Use below code in your course node template.
print theme_render_template(drupal_get_path('theme', 'YOUR_THEME_NAME') . 'PATH_TO_TEMPLATE/subject-node.tpl.php', $subject_node_object);

You need to create a template for you subject content type fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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