function _forum_parent_select
Returns a select box for available parent terms.
Parameters
$tid: ID of the term that is being added or edited.
$title: Title for the select box.
$child_type: Whether the child is a forum or a container.
Return value
A select form element.
2 calls to _forum_parent_select()
- forum_form_container in modules/
forum/ forum.admin.inc - Form constructor for adding and editing forum containers.
- forum_form_forum in modules/
forum/ forum.admin.inc - Form constructor for adding and editing a forum.
File
-
modules/
forum/ forum.admin.inc, line 315
Code
function _forum_parent_select($tid, $title, $child_type) {
$parents = taxonomy_get_parents($tid);
if ($parents) {
$parent = array_shift($parents);
$parent = $parent->tid;
}
else {
$parent = 0;
}
$vid = variable_get('forum_nav_vocabulary', '');
$children = taxonomy_get_tree($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($vid);
$options[0] = '<' . t('root') . '>';
if ($tree) {
foreach ($tree as $term) {
if (!in_array($term->tid, $exclude)) {
$options[$term->tid] = str_repeat(' -- ', $term->depth) . $term->name;
}
}
}
if ($child_type == 'container') {
$description = t('Containers are usually placed at the top (root) level, but may also be placed inside another container or forum.');
}
elseif ($child_type == 'forum') {
$description = t('Forums may be placed at the top (root) level, or inside another container or forum.');
}
return array(
'#type' => 'select',
'#title' => $title,
'#default_value' => $parent,
'#options' => $options,
'#description' => $description,
'#required' => TRUE,
);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.