_forum_parent_select

Definition

_forum_parent_select($tid, $title, $name)
modules/forum.module, line 197

Description

Returns a select box for available parent terms

Parameters

$tid ID of the term which is being added or edited

$title Title to display the select box with

$name Name to use in the forum

Code

<?php
function _forum_parent_select($tid, $title, $name) {

  $parents = taxonomy_get_parents($tid);
  if ($parents) {
    $parent = array_shift($parents);
    $parent = $parent->tid;
  }
  else {
    $parent = 0;
  }

  $children = taxonomy_get_tree(_forum_get_vid, $tid);

  // A term can't be the child of itself, nor of its children.
  foreach ($children as $child) {
    $exclude[] = $child->tid;
  }
  $exclude[] = $tid;

  $tree = taxonomy_get_tree(_forum_get_vid());
  $options[0] = '<'. t('root') .'>';
  if ($tree) {
    foreach ($tree as $term) {
      if (!in_array($term->tid, $exclude)) {
        $options[$term->tid] = _forum_depth($term->depth).$term->name;
      }
    }
  }

  return form_select($title, $name, $parent, $options, NULL, 0, FALSE, TRUE);
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.