_forum_parent_select
- Versions
- 4.6
_forum_parent_select($tid, $title,$name)- 4.7 – 7
_forum_parent_select($tid, $title, $child_type)
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
modules/forum.module, line 197
<?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);
}
?>Login or register to post comments 