tutorial

Step 2 - Create a new node.tpl using this view.

The key to making this all work is to create a node.tpl for this node type which pulls in the view which we just created.

// basically for preview case for intial create when we don't yet have a NID
if (!$node->nid) {
  include (path_to_theme() . "/node.tpl.php");
  return;
}

$view = views_get_view('news_override');
$view->set_arguments(array($node->nid, 'all'));

echo $view->preview();

Step 1 - Using Views to collect related content.

The first thing we'll want to do is gather the related information that is contained within nodes linked to our primary node.

Select row style as fields

Create a relationship.

Add fields from the other nodes using our relationships

Using Views to Create Nodes with Related Content

Back in the days of Drupal 4 and 5 there was a popular module called Contemplate. This module allowed the site designer to modify the default node.tpl by adding PHP code or re-arranging node fields as required. This tpl was then stored ion the db.

This module still exists but has no ability (short of writing PHP code) to modify node templates to include related content (i.e. content from other nodes which are related to the primary node via something like a nodereference or userreference field.

Syndicate content