function nodehierarchy_views_embed_children in Node Hierarchy 6
Same name and namespace in other branches
- 5 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_embed_children()
- 6.3 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_embed_children()
- 6.2 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_embed_children()
- 7.4 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_embed_children()
- 7.2 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_nodeapi in nodehierarchy_views/
nodehierarchy_views.module - Implmentation of hook_nodeapi().
File
- nodehierarchy_views/
nodehierarchy_views.module, line 128 - Views.module integration for nodehierarchy.module.
Code
function nodehierarchy_views_embed_children(&$node) {
if (@$node->nh_children_view && ($view = views_get_view($node->nh_children_view))) {
// make sure the first argument is a node hierarchy parent argument
// Copy the args for PHP 4 compatibility.
$args = (array) $view->display['default']->display_options['arguments'];
$first_arg = current($args);
if (!$first_arg || $first_arg['field'] !== "parent" && $first_arg['field'] !== "antecedent" || $first_arg['table'] !== "nodehierarchy") {
$view->display['default']->display_options['arguments'] = array_merge(array(
'parent' => array(
'id' => 'parent',
'table' => 'nodehierarchy',
'field' => 'parent',
'default_action' => 'not found',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
),
), $view->display['default']->display_options['arguments']);
}
// Get the arguments to send to the view.
$arguments = explode('/', $_GET['q']);
// First arg will be 'node', remove it.
array_shift($arguments);
// The next argument is the nid, this we will pass as the parent,
// the rest may be added by the view (feed selectors, calendar params etc)
// Set the url of the view so that filters and arguments work.
// NB: setting this to just 'node' works since the nid will be added by the
// argument code in views (first arg is always the nid). This works but may
// be taking advantage of a non-api side effect and should be treated with
// caution.
$view->url = "node";
$node->content['nodehierarchy_children'] = array(
"#value" => $view
->execute_display('default', $arguments),
"#weight" => 10,
);
}
}