theme_links

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

includes/theme.inc, строка 542

Версии
5 – 6
theme_links($links, $attributes = array('class' => 'links'))

Возвращает темизированный набор ссылок.

Параметры

$links Ассоциативный массив ссылок, которые нужно темизировать.

$attributes Ассоциативный массив HTML аттрибутов.

Возвращаемое значение

Строка, содержащая список ссылок.

Связанные темы

▾ 10 функции вызывают theme_links()

aggregator_page_categories in modules/aggregator/aggregator.module
Коллбэк меню; показывает все категории, используемые аггрегатором.
aggregator_page_sources in modules/aggregator/aggregator.module
Коллбэк меню; показывает все фиды, используемые аггрегатором.
chameleon_comment in themes/chameleon/chameleon.theme
chameleon_node in themes/chameleon/chameleon.theme
chameleon_page in themes/chameleon/chameleon.theme
phptemplate_comment in themes/engines/phptemplate/phptemplate.engine
Prepare the values passed to the theme_comment function to be passed into a pluggable template engine.
phptemplate_node in themes/engines/phptemplate/phptemplate.engine
Prepare the values passed to the theme_node function to be passed into a pluggable template engine.
theme_comment in modules/comment/comment.module
theme_node in includes/theme.inc
Возвращает темизированную ноду.
theme_poll_results in modules/poll/poll.module

Код

<?php
function theme_links($links, $attributes = array('class' => 'links')) {
  $output = '';

  if (count($links) > 0) {
    $output = '<ul'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = $key;

      // Automatically add a class to each link and also to each LI
      if (isset($link['attributes']) && isset($link['attributes']['class'])) {
        $link['attributes']['class'] .= ' ' . $key;
      }
      else {
        $link['attributes']['class'] = $key;
      }

      // Add first and last classes to the list of links to help out themers.
      $extra_class = '';
      if ($i == 1) {
        $extra_class .= 'first ';
      }
      if ($i == $num_links) {
        $extra_class .= 'last ';
      }
      $output .= '<li '. drupal_attributes(array('class' => $extra_class . $class)) .'>';

      // Is the title HTML?
      $html = isset($link['html']) && $link['html'];

      // Initialize fragment and query variables.
      $link['query'] = isset($link['query']) ? $link['query'] : NULL;
      $link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;

      if (isset($link['href'])) {
        $output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
      }
      else if ($link['title']) {
        //Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (!$html) {
          $link['title'] = check_plain($link['title']);
        }
        $output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
      }

      $i++;
      $output .= "</li>\n";
    }

    $output .= '</ul>';
  }

  return $output;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

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