You are here

function _nodehierarchy_get_parent_pulldown in Node Hierarchy 5

Same name and namespace in other branches
  1. 6 nodehierarchy.module \_nodehierarchy_get_parent_pulldown()

Get the parent selector pulldown.

1 call to _nodehierarchy_get_parent_pulldown()
nodehierarchy_nodehierarchyapi in ./nodehierarchy.module
Implementation of hook_nodehierarchyapi(). Responds to own api calls.

File

./nodehierarchy.module, line 1039
A module to make nodes hierarchical.

Code

function _nodehierarchy_get_parent_pulldown($child_type, $default, $title, $nid = NULL) {

  // $child_type is currently unused.
  $types = array();
  foreach (node_get_types() as $key => $type) {
    if (variable_get('nh_parent_' . $key, FALSE)) {
      $types[] = "'{$key}'";
    }
  }
  if ($types) {
    $items = array(
      0 => '-- ' . t('NONE') . ' --',
    );
    $items += _nodehierarchy_get_parent_pulldown_items($parent_id, $types, $nid);

    // add the default if it's not alredy there.
    if (!isset($items[$default])) {
      $default_node = node_load($default);
      $items += array(
        $default => $default_node->title,
      );
    }
    $out = array(
      '#type' => 'select',
      '#title' => $title,
      '#default_value' => $default,
      '#options' => $items,
    );
  }
  return $out;
}