file page.html.twig

Default theme implementation to display a single page.

The doctype, html, head and body tags are not in this template. Instead they can be found in the html.html.twig template in this directory.

Available variables:

General utility variables:

  • base_path: The base URL path of the Drupal installation. Will usually be "/" unless you have installed Drupal in a sub-directory.
  • is_front: A flag indicating if the current page is the front page.
  • logged_in: A flag indicating if the user is registered and signed in.
  • is_admin: A flag indicating if the user has permission to access administration pages.
Site identity:
  • front_page: The URL of the front page. Use this instead of base_path when linking to the front page. This includes the language domain or prefix.
Page content (in order of occurrence in the default page.html.twig):
  • title_prefix: Additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • title: The page title, for use in the actual content.
  • title_suffix: Additional output populated by modules, intended to be displayed after the main title tag that appears in the template.
  • messages: Status and error messages. Should be displayed prominently.
  • tabs: Tabs linking to any sub-pages beneath the current page (e.g., the view and edit tabs when displaying a node).
  • node: Fully loaded node, if there is an automatically-loaded node associated with the page and the node ID is the second argument in the page's path (e.g. node/12345 and node/12345/revisions, but not comment/reply/12345).
Regions:
  • page.header: Items for the header region.
  • page.navigation: Items for the navigation region.
  • page.navigation_collapsible: Items for the navigation (collapsible) region.
  • page.highlighted: Items for the highlighted content region.
  • page.help: Dynamic help text, mostly for admin pages.
  • page.content: The main content of the current page.
  • page.sidebar_first: Items for the first sidebar.
  • page.sidebar_second: Items for the second sidebar.
  • page.footer: Items for the footer region.
Source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation to display a single page.
  5. *
  6. * The doctype, html, head and body tags are not in this template. Instead they
  7. * can be found in the html.html.twig template in this directory.
  8. *
  9. * Available variables:
  10. *
  11. * General utility variables:
  12. * - base_path: The base URL path of the Drupal installation. Will usually be
  13. * "/" unless you have installed Drupal in a sub-directory.
  14. * - is_front: A flag indicating if the current page is the front page.
  15. * - logged_in: A flag indicating if the user is registered and signed in.
  16. * - is_admin: A flag indicating if the user has permission to access
  17. * administration pages.
  18. *
  19. * Site identity:
  20. * - front_page: The URL of the front page. Use this instead of base_path when
  21. * linking to the front page. This includes the language domain or prefix.
  22. *
  23. * Page content (in order of occurrence in the default page.html.twig):
  24. * - title_prefix: Additional output populated by modules, intended to be
  25. * displayed in front of the main title tag that appears in the template.
  26. * - title: The page title, for use in the actual content.
  27. * - title_suffix: Additional output populated by modules, intended to be
  28. * displayed after the main title tag that appears in the template.
  29. * - messages: Status and error messages. Should be displayed prominently.
  30. * - tabs: Tabs linking to any sub-pages beneath the current page (e.g., the
  31. * view and edit tabs when displaying a node).
  32. * - node: Fully loaded node, if there is an automatically-loaded node
  33. * associated with the page and the node ID is the second argument in the
  34. * page's path (e.g. node/12345 and node/12345/revisions, but not
  35. * comment/reply/12345).
  36. *
  37. * Regions:
  38. * - page.header: Items for the header region.
  39. * - page.navigation: Items for the navigation region.
  40. * - page.navigation_collapsible: Items for the navigation (collapsible) region.
  41. * - page.highlighted: Items for the highlighted content region.
  42. * - page.help: Dynamic help text, mostly for admin pages.
  43. * - page.content: The main content of the current page.
  44. * - page.sidebar_first: Items for the first sidebar.
  45. * - page.sidebar_second: Items for the second sidebar.
  46. * - page.footer: Items for the footer region.
  47. *
  48. * @ingroup templates
  49. *
  50. * @see template_preprocess_page()
  51. * @see html.html.twig
  52. */
  53. #}
  54. {% set container = theme.settings.fluid_container ? 'container-fluid' : 'container' %}
  55. {# Navbar #}
  56. {% if page.navigation or page.navigation_collapsible %}
  57. {% block navbar %}
  58. {%
  59. set navbar_classes = [
  60. 'navbar',
  61. theme.settings.navbar_inverse ? 'navbar-inverse' : 'navbar-default',
  62. theme.settings.navbar_position ? 'navbar-' ~ theme.settings.navbar_position|clean_class : container,
  63. ]
  64. %}
  65. <header{{ navbar_attributes.addClass(navbar_classes) }} id="navbar" role="banner">
  66. {% if not navbar_attributes.hasClass(container) %}
  67. <div class="{{ container }}">
  68. {% endif %}
  69. <div class="navbar-header">
  70. {{ page.navigation }}
  71. {# .btn-navbar is used as the toggle for collapsed navbar content #}
  72. {% if page.navigation_collapsible %}
  73. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse">
  74. <span class="sr-only">{{ 'Toggle navigation'|t }}</span>
  75. <span class="icon-bar"></span>
  76. <span class="icon-bar"></span>
  77. <span class="icon-bar"></span>
  78. </button>
  79. {% endif %}
  80. </div>
  81. {# Navigation (collapsible) #}
  82. {% if page.navigation_collapsible %}
  83. <div id="navbar-collapse" class="navbar-collapse collapse">
  84. {{ page.navigation_collapsible }}
  85. </div>
  86. {% endif %}
  87. {% if not navbar_attributes.hasClass(container) %}
  88. </div>
  89. {% endif %}
  90. </header>
  91. {% endblock %}
  92. {% endif %}
  93. {# Main #}
  94. {% block main %}
  95. <div role="main" class="main-container {{ container }} js-quickedit-main-content">
  96. <div class="row">
  97. {# Header #}
  98. {% if page.header %}
  99. {% block header %}
  100. <div class="col-sm-12" role="heading">
  101. {{ page.header }}
  102. </div>
  103. {% endblock %}
  104. {% endif %}
  105. {# Sidebar First #}
  106. {% if page.sidebar_first %}
  107. {% block sidebar_first %}
  108. <aside class="col-sm-3" role="complementary">
  109. {{ page.sidebar_first }}
  110. </aside>
  111. {% endblock %}
  112. {% endif %}
  113. {# Content #}
  114. {%
  115. set content_classes = [
  116. page.sidebar_first and page.sidebar_second ? 'col-sm-6',
  117. page.sidebar_first and page.sidebar_second is empty ? 'col-sm-9',
  118. page.sidebar_second and page.sidebar_first is empty ? 'col-sm-9',
  119. page.sidebar_first is empty and page.sidebar_second is empty ? 'col-sm-12'
  120. ]
  121. %}
  122. <section{{ content_attributes.addClass(content_classes) }}>
  123. {# Highlighted #}
  124. {% if page.highlighted %}
  125. {% block highlighted %}
  126. <div class="highlighted">{{ page.highlighted }}</div>
  127. {% endblock %}
  128. {% endif %}
  129. {# Help #}
  130. {% if page.help %}
  131. {% block help %}
  132. {{ page.help }}
  133. {% endblock %}
  134. {% endif %}
  135. {# Content #}
  136. {% block content %}
  137. <a id="main-content"></a>
  138. {{ page.content }}
  139. {% endblock %}
  140. </section>
  141. {# Sidebar Second #}
  142. {% if page.sidebar_second %}
  143. {% block sidebar_second %}
  144. <aside class="col-sm-3" role="complementary">
  145. {{ page.sidebar_second }}
  146. </aside>
  147. {% endblock %}
  148. {% endif %}
  149. </div>
  150. </div>
  151. {% endblock %}
  152. {% if page.footer %}
  153. {% block footer %}
  154. <footer class="footer {{ container }}" role="contentinfo">
  155. {{ page.footer }}
  156. </footer>
  157. {% endblock %}
  158. {% endif %}

Related topics