Drupal 8 в шаблоне bootstrap вывести дополнительные поля в заголовок

Главные вкладки

Аватар пользователя skoribchenko skoribchenko 27 марта 2019 в 19:06

Привет всем. Задача такая - создал сабтему на bootstrap. По задаче - есть подзаголовок, который должен находиться выше заголовка h1.
В материале я создал поле field_podzagolovok
Правильно ли я понимаю, что его нужно выводить в шаблоне page-title.html.twig?
И если да, то каким образом?

{% if title %}
{{ title }}
{% endif %}

Комментарии

Аватар пользователя sas@drupal.org sas@drupal.org 28 марта 2019 в 8:55

Я бы добавил на _preprocess в title_prefix для page-title.html.twig
см. например

/**
 * Implements hook_preprocess_HOOK() for page title templates.
 */

function bartik_preprocess_page_title(&$variables) {
  // Since the title and the shortcut link are both block level elements,
  // positioning them next to each other is much simpler with a wrapper div.
  if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
    // Add a wrapper div using the title_prefix and title_suffix render
    // elements.
    $variables['title_prefix']['shortcut_wrapper'] = [
      '#markup' => '<div class="shortcut-wrapper clearfix">',
      '#weight' => 100,
    ];
    $variables['title_suffix']['shortcut_wrapper'] = [
      '#markup' => '</div>',
      '#weight' => -99,
    ];
    // Make sure the shortcut link is the first item in title_suffix.
    $variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
  }
}