Hoping someone can point me in the right direction here.

I am using Node Relativity, and I have added a video to the parent node and want it to appear on all child nodes as well.

I've tried doing this with a node_load->nid, but I cant figure out how to get the [view] for the field. I'm thinking I have to run this through a theme function?

$nid = $parent_node;
$parent = node_load($nid);
if ($parent->field_video[0]) {
do something here...
}

Just for a test I ran it through theme_video_cck_video_embed using the code suggested in the video_cck.module and that works perfectly, printing everything in a nice form text area.

I take it need to use theme('video_cck_video_video', $field, $item, $formatter, $node); but I cant figure out how that is working.

Any pointers much appreciated.

Comments

alex ua’s picture

Status: Active » Postponed (maintainer needs more info)

The print command you're looking for should be something like:
print $parent->field_video[0]['view']

Does that not work?

Jeff Burnz’s picture

Unfortunately it does not - when you do the node_load, [view] is not available.

aaron’s picture

correct. you would need to use node_view($parent) after loading it before you have access to the ->field_video array

Jeff Burnz’s picture

Hey, thanks so much for that aaron, works a charm, I had been tinkering with the node_view but no joy until now, thanks again, much appreciated both of you...

Heres the solution to print emfield video_cck video parent video in the child nodes (I use this in my child node node-xxx.tpl.php file)

$nid = $parent_node;
$parent = node_load($nid);
node_view($parent);
if ($parent->field_video[0]['view']) {
print $parent->field_video[0]['view'];
}
aaron’s picture

Status: Postponed (maintainer needs more info) » Fixed

that will work fine, but a more technically "correct" solution would be something like the following:

$nid = $parent_node;
$parent = node_load($nid);
node_view($parent);
if ($parent->field_video[0]['value']) {
  print $parent->field_video[0]['view'];
}

there might be some circumstances that $parent->field_video[0]['view'] would not be empty, even if there were no video. although that would only be if you were overriding the theme or using a custom provider, so what you have would work for nearly every circumstance. for instance, someone might want to override the theme to have a thumbnail saying 'no video available' when the value is empty, but not want that on teasers. this solution would be better for that type of implementation.

aaron

aaron’s picture

also, be careful with node_loads. in most circumstances, there's almost always a way to do what you want with a list view, which will only load the necessary fields. node_load with node_view is query intensive, which can cause performance issues for high load sites.

Jeff Burnz’s picture

Yes, thats a good point you make there, since I did not need to worry about it I used 'view', but for others it may be important, thanks for pointing that out.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.