You are here

function nodehierarchy_views_nodehierarchyapi in Node Hierarchy 5

Same name and namespace in other branches
  1. 6 nodehierarchy_views/nodehierarchy_views.module \nodehierarchy_views_nodehierarchyapi()

Implementation of hook_nodehierarchyapi().

File

nodehierarchy_views/nodehierarchy_views.module, line 44
Views.module integration for nodehierarchy.module.

Code

function nodehierarchy_views_nodehierarchyapi($op, $node) {
  switch ($op) {
    case "node_type_form":
      $form = array();
      if (nodehierarchy_node_can_be_parent($node)) {
        $form['nh_default_children_view'] = array(
          '#type' => 'select',
          '#title' => "Default Children View",
          '#multiple' => FALSE,
          '#options' => _nodehierarchy_views_view_options(),
          '#required' => FALSE,
          '#default_value' => variable_get('nh_default_children_view_' . $node->type, NULL),
          '#description' => t("Default for the embed children view feature."),
        );
      }
      return $form;
      break;
    case "node_form":
      $form = array();
      if (user_access('edit embedded child view') && nodehierarchy_node_can_be_parent($node)) {
        $form['nh_children_view'] = array(
          '#type' => 'select',
          '#title' => "Embed Children View",
          '#multiple' => FALSE,
          '#options' => _nodehierarchy_views_view_options(),
          '#required' => FALSE,
          '#default_value' => $node->nh_children_view === NULL ? variable_get('nh_default_children_view_' . $node->type, NULL) : $node->nh_children_view,
          '#description' => t("Embed a view containing this node's children into the node's page view"),
        );
      }
      return $form;
      break;
  }
}