1

This question could be asked in numerous ways, so I'm just going to explain my situation.

I currently have a block that works fine listing any child nodes (node reference is used between the nodes). This works as it uses an Argument for the Node ID so it can list all the children in a nice list.

However, I wish to have this very list of child nodes - displayed in a sort of "Teaser List" from a seperate view. The reason this "new" view wont work - is because there is currently no Node ID to reference the children - as the block doesn't sit on the parent page anymore.

So my initial solution was to embed a view using views_embed_view with something like:

print views_embed_view('show_units_display', 'block_1', $node->nid);

And I would have this in my views template file for each result row. But seeing as the view itself sits on an entirely seperate page - no Node ID is passed here and there no results are displayed!

My overall outcome would look like this:

Node 1 - title
Node 1 - body

-- display list of children of node 1 here --

Node 2 - title
Node 2 - body

-- display list of children of node 2 here --

And so on...

Any help would be brilliant!
Cheers,
Garry.

2 Answers 2

1

In your Views row template, you should have access to $row which store all the records retrieved for this row and especially $row->nid which is the nid you want to pass it to the block of your row-footer view.

2

A Computed Field on the node itself can also pass the NID to a view, regardless of the page it's displayed on.

Add a Computed Field to the node type.

in Computed Code:

$node_field[0]['value'] = $node->nid;

in Display Format:

$display = views_embed_view('VIEWNAME','DISPLAY', $node_field_item['value']);

If you store it in the database, then the field can be called in via Views.

1
  • Thanks for the response, I did what I believe is a slightly less complicated way by just adding the views_embed_view() into a views tpl file for the Row Style. print views_embed_view('show_units_display','block_1', $nid);
    – Garry
    Jul 13, 2011 at 13:31

Your Answer

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

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