You are here

function nodehierarchy_views_embed_children in Node Hierarchy 7.2

Same name and namespace in other branches
  1. 5 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_embed_children()
  2. 6.3 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_embed_children()
  3. 6 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_embed_children()
  4. 6.2 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_embed_children()
  5. 7.4 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_embed_children()

Add the embedded children view to the node body if appropriate.

1 call to nodehierarchy_views_embed_children()
nodehierarchy_views_node_view in nodehierarchy_views/nodehierarchy_views.module
Implements hook_node_view().

File

nodehierarchy_views/nodehierarchy_views.module, line 230
Embed a view of children onto a node.

Code

function nodehierarchy_views_embed_children(&$node) {
  $display = @$node->nh_children_view_display ? @$node->nh_children_view_display : 'default';

  // Get the arguments to send to the view. This should allow other view arguments to still work.
  $arguments = explode('/', $_GET['q']);

  // First arg will be 'node', the second will be the node id. Remove them.
  array_shift($arguments);
  array_shift($arguments);

  // Add the node id of the given node.
  array_unshift($arguments, $node->nid);

  // Defer the rendering of the view until the theme function so it can be overriden or altered.
  $node->content['nodehierarchy_children'] = array(
    '#theme' => 'nodehierarchy_children_embed',
    '#nodehierarchy_view' => empty($node->nh_children_view) ? null : $node->nh_children_view,
    '#nodehierarchy_view_display' => @$node->nh_children_view_display ? @$node->nh_children_view_display : 'default',
    '#nodehierarchy_view_args' => $arguments,
  );
  $node->content['nodehierarchy_children_links'] = theme('nodehierarchy_new_child_links', array(
    'node' => $node,
  ));
}