_forum_parent_select

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

modules/forum/forum.module, строка 609

Версии
5 – 6
_forum_parent_select($tid, $title, $child_type)

Returns a select box for available parent terms

Параметры

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

$title Title to display the select box with

$child_type Whether the child is forum or container

▾ 2 функции вызывают _forum_parent_select()

forum_form_container in modules/forum/forum.module
Returns a form for adding a container to the forum vocabulary
forum_form_forum in modules/forum/forum.module
Returns a form for adding a forum to the forum vocabulary

Код

<?php
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;
  }

  $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] = str_repeat(' -- ', $term->depth) . $term->name;
      }
    }
  }
  if ($child_type == 'container') {
    $description = t('Containers are usually placed at the top (root) level of your forum but you can also place a container inside a parent container or forum.');
  }
  else if ($child_type == 'forum') {
    $description = t('You may place your forum inside a parent container or forum, or at the top (root) level of your forum.');
  }

  return array('#type' => 'select', '#title' => $title, '#default_value' => $parent, '#options' => $options, '#description' => $description, '#required' => TRUE);
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему