Block view content relative to the page it's on in Drupal 6

690 views Asked by At

I want to make a Views block's content show things that's related to the page I'm on. For example I have a content type 'Parent' that has many nodes of type 'Child' related to it, so on the 'Parent' node I want to show all 'Children' in my block.

Not that complicated but I just can't get it to work. I've been using the Node Relativity module to setup the Parent-Child relationship and then I tried adding an argument in the View to filter the Child nodes. The problem with this is I can't get the Parent ID saved from the Child node + I can't really get the ID of the page I'm on (the Parent's ID) either without using a the URL argument, which means no clean URLs.

I experimented with saving the ID of the parent as a taxonomy term for the Child nodes. The problem with this is I want the Parent-Child relationship to be setup automatically when creating a new node (by using the current page's ID as a parameter when creating a new node).

Maybe I'm looking at this from the wrong angle though... Does someone have any insight in this?

2

There are 2 answers

2
jpstrikesback On BEST ANSWER

What you want is views attach so that on a given node you can show things related to that node. Check out this recipe from Mustardseed Media for making related content creation & views things rather easy.

0
Sean Buscay On

Views attach would do it, but doesn't it attach to the node content rather than as a block?

To do it in a block, create a views block with the parent node reference id as the views argument.

Then select to provide the views default argument. With views 2 I think you can just use "Provide node id from URL". If that doesn't work then provide the argument with PHP and enter this as the php:

<?php if (arg(0) == 'yourcontenttype' && arg(1) != '') {  return arg(1); } ?>

Let me know how that works for you.