Вы здесь

Друпал 7: block.tpl.php

block.tpl.php — шаблон формирующий блок.

Переменные

Основные

  • $block->subject — заголовок блока
  • $content — содержание блока
  • $block->module — название модуля генерирующего блок
  • $block->delta — порядковый номер блока (который генерируется одним модулем)
  • $block->region — регион блока
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default values can be one or more of the following:
    • block: The current template type, i.e., "theming hook"
    • block-[module]: The module generating the block. For example, the user module is responsible for handling the default user navigation block. In that case the class would be "block-user"
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template

Вспомогательные

  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes
  • $block_zebra— добавление классов odd и even (используется для оформления с помощью CSS)
  • $zebra — то же самое что $block_zebra, но для каждого региона odd и even сбрасывается и начинаются снова с odd
  • $block_id — идентификатор блока (счётчик блоков в регионе; первый блок — 1, второй блок — 2 и т.д.)
  • $id — то же самое, что $block_id, но для каждого региона идентификатор сбрасывается и начинается снова с 1
  • $is_front — возвращает значение 1 (TRUE, если загружена первая страница сайта) или 0 (FALSE, если загружена любая другая страница)
  • $logged_in — возвращает значение 1 (TRUE, если текущий пользователь залогинен) или 0 (FALSE, если это анонимный посетитель)
  • $is_admin — возвращает значение 1 (TRUE, если текущий пользователь администратор) или 0 (FALSE, если текущий пользователь не является администратором)
  • $block_html_id: A valid HTML ID and guaranteed unique

Пример шаблона

<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

  <?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
  <h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
<?php endif;?>
  <?php print render($title_suffix); ?>

  <div class="content"<?php print $content_attributes; ?>>
    <?php print $content ?>
  </div>
</div>