You are here

function template_preprocess_book_export_html in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/book/book.module \template_preprocess_book_export_html()
  2. 6 modules/book/book.module \template_preprocess_book_export_html()
  3. 7 modules/book/book.module \template_preprocess_book_export_html()
  4. 9 core/modules/book/book.module \template_preprocess_book_export_html()

Prepares variables for book export templates.

Default template: book-export-html.html.twig.

Parameters

array $variables: An associative array containing:

  • title: The title of the book.
  • contents: Output of each book page.
  • depth: The max depth of the book.

File

core/modules/book/book.module, line 470
Allows users to create and organize related content in an outline.

Code

function template_preprocess_book_export_html(&$variables) {
  global $base_url;
  $language_interface = \Drupal::languageManager()
    ->getCurrentLanguage();
  $variables['base_url'] = $base_url;
  $variables['language'] = $language_interface;
  $variables['language_rtl'] = $language_interface
    ->getDirection() == LanguageInterface::DIRECTION_RTL;

  // HTML element attributes.
  $attributes = [];
  $attributes['lang'] = $language_interface
    ->getId();
  $attributes['dir'] = $language_interface
    ->getDirection();
  $variables['html_attributes'] = new Attribute($attributes);
}