Drupal API

hook_view

  • Drupal 5
  • Drupal 6
Говорят, 10% посетителей этого сайта — американцы, приходящие с гугла. Не оставим супостату ничего, даешь полный перевод документации!

developer/hooks/node.php, строка 398

Версии
5 – 6
hook_view($node, $teaser = FALSE, $page = FALSE)

Показывает ноду.

Этот хук используется нода-модулями. Он разрешает модулю определить свой метод показа его нод, обычно путём показа дополнительной информации специфичной для этого типа нод.

Подробный пример использования смотрите в node_example.module.

Параметры

$node Нода, которую нужно показать.

$teaser Whether we are to generate a 'teaser' or summary of the node, rather than display the whole thing.

$page Whether the node is being displayed as a standalone page. If this is TRUE, the node title should not be displayed, as it will be printed automatically by the theme system. Also, the module may choose to alter the default breadcrumb trail in this case.

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

$node. The passed $node parameter should be modified as necessary and returned so it can be properly presented. Nodes are prepared for display by assembling a structured array in $node->content, rather than directly manipulating $node->body and $node->teaser. The format of this array is the same used by the Forms API. As with FormAPI arrays, the #weight property can be used to control the relative positions of added elements. If for some reason you need to change the body or teaser returned by node_prepare(), you can modify $node->content['body']['#value']. Note that this will be the un-rendered content. To modify the rendered output, see hook_nodeapi($op = 'alter').

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

Код

<?php
function hook_view($node, $teaser = FALSE, $page = FALSE) {
  if ($page) {
    $breadcrumb = array();
    $breadcrumb[] = array('path' => 'example', 'title' => t('example'));
    $breadcrumb[] = array('path' => 'example/'. $node->field1,
      'title' => t('%category', array('%category' => $node->field1)));
    $breadcrumb[] = array('path' => 'node/'. $node->nid);
    menu_set_location($breadcrumb);
  }
  $node = node_prepare($node, $teaser);
  $node->content['myfield'] = array(
    '#value' => theme('mymodule_myfield', $node->myfield),
    '#weight' => 1,
  );
  return $node;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

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

Что такое OpenID?
  • Регистрация
  • Забыли пароль?

Документация

  • Drupal 6
  • Константы
  • Файлы
  • Функции
  • Глобальные переменные
  • Разделы