How to show a view after the node content

Antinoo - September 20, 2009 - 08:23

I've created two content types, Father and Son.

A Father, as you probably already know :), can have multiple Sons.
The Son content type has a "Node reference" CCK field called "field_father".

When the user goes on /father/123 (where 123 is the nid), it's shown the Father node 123 and then the "Add new comment" form.

Now, I'd like to show a summary of its Sons (I've already created it using the Views module), instead of the form to add comments.

In other words, I want to display a view on bottom of a node content: how can I do that using Drupal 6?

I would avoid editing the theme template files by hand, since I will use another theme (I still don't know which one).

I've just installed the Panels module: can I use it for this purpose?

Thanks for any advice.

Giovanni

From what I understand, for

talino - September 20, 2009 - 15:04

From what I understand, for this type of situation you *will* have to edit a template file, although it's not a big deal.

If your "father" nodes don't use a custom template, duplicate node.tpl.php and call it node-father.tpl.php (if your custom content-type's machine-readable name is called "father", otherwise modify the filename accordingly).

Then, in the template file, add the following where your want your view to be added:

print views_embed_view('VIEW_NAME', 'VIEW_DISPLAY');

Replace VIEW_DISPLAY with 'page_1' or 'block_1', for example.

It's possible to send arguments to Views this way. For example, if a view has an argument of "User : User ID" and is set to filter only Blog Posts, then it's possible to show a list of blog posts by the author of the node by adding:

print views_embed_view('VIEW_NAME', 'VIEW_DISPLAY', $node->uid);

This gets the User ID of the $node being output and sends it as an argument to the view being embedded.

Also checkout :

http://thedrupalblog.com/embedding-view-drupal-6-using-views-embed-view
http://drupal.org/node/11816

Hope this helps.

Or you could try using

adam_b - September 20, 2009 - 20:44
 
 

Drupal is a registered trademark of Dries Buytaert.