You are here

function nodehierarchy_views_insert in Node Hierarchy 7.4

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

Insert the given embedded view.

1 call to nodehierarchy_views_insert()
nodehierarchy_views_node_insert in nodehierarchy_views/nodehierarchy_views.module
Implements hook_node_insert().

File

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

Code

function nodehierarchy_views_insert($node) {

  // If the user has access to edit the view, update as usual.
  if (user_access('edit embedded child view')) {
    nodehierarchy_views_update($node);
  }
  elseif ($children_view = variable_get('nh_default_children_view_' . $node->type, NULL)) {
    list($view, $display) = explode(':', $children_view);
    $id = db_insert('nodehierarchy_views')
      ->fields(array(
      'nid' => $node->nid,
      'nh_children_view' => $view,
    ))
      ->execute();
  }
}