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.
Navigation:
  • breadcrumb: The breadcrumb trail for the current page.
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).
  • action_links: Actions local to the page, such as "Add menu" on the menu administration interface.
  • 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.

See Also

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. * Navigation:
  24. * - breadcrumb: The breadcrumb trail for the current page.
  25. *
  26. * Page content (in order of occurrence in the default page.html.twig):
  27. * - title_prefix: Additional output populated by modules, intended to be
  28. * displayed in front of the main title tag that appears in the template.
  29. * - title: The page title, for use in the actual content.
  30. * - title_suffix: Additional output populated by modules, intended to be
  31. * displayed after the main title tag that appears in the template.
  32. * - messages: Status and error messages. Should be displayed prominently.
  33. * - tabs: Tabs linking to any sub-pages beneath the current page (e.g., the
  34. * view and edit tabs when displaying a node).
  35. * - action_links: Actions local to the page, such as "Add menu" on the menu
  36. * administration interface.
  37. * - node: Fully loaded node, if there is an automatically-loaded node
  38. * associated with the page and the node ID is the second argument in the
  39. * page's path (e.g. node/12345 and node/12345/revisions, but not
  40. * comment/reply/12345).
  41. *
  42. * Regions:
  43. * - page.header: Items for the header region.
  44. * - page.navigation: Items for the navigation region.
  45. * - page.navigation_collapsible: Items for the navigation (collapsible) region.
  46. * - page.highlighted: Items for the highlighted content region.
  47. * - page.help: Dynamic help text, mostly for admin pages.
  48. * - page.content: The main content of the current page.
  49. * - page.sidebar_first: Items for the first sidebar.
  50. * - page.sidebar_second: Items for the second sidebar.
  51. * - page.footer: Items for the footer region.
  52. *
  53. * @ingroup templates
  54. *
  55. * @see template_preprocess_page()
  56. * @see html.html.twig
  57. */
  58. #}
  59. {% set container = theme.settings.fluid_container ? 'container-fluid' : 'container' %}
  60. {# Navbar #}
  61. {% if page.navigation or page.navigation_collapsible %}
  62. {% block navbar %}
  63. {%
  64. set navbar_classes = [
  65. 'navbar',
  66. theme.settings.navbar_inverse ? 'navbar-inverse' : 'navbar-default',
  67. theme.settings.navbar_position ? 'navbar-' ~ theme.settings.navbar_position|clean_class : container,
  68. ]
  69. %}
  70. <header{{ navbar_attributes.addClass(navbar_classes) }} id="navbar" role="banner">
  71. {% if not navbar_attributes.hasClass('container') %}
  72. <div class="{{ container }}">
  73. {% endif %}
  74. <div class="navbar-header">
  75. {{ page.navigation }}
  76. {# .btn-navbar is used as the toggle for collapsed navbar content #}
  77. {% if page.navigation_collapsible %}
  78. <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse">
  79. <span class="sr-only">{{ 'Toggle navigation'|t }}</span>
  80. <span class="icon-bar"></span>
  81. <span class="icon-bar"></span>
  82. <span class="icon-bar"></span>
  83. </button>
  84. {% endif %}
  85. </div>
  86. {# Navigation (collapsible) #}
  87. {% if page.navigation_collapsible %}
  88. <div id="navbar-collapse" class="navbar-collapse collapse">
  89. {{ page.navigation_collapsible }}
  90. </div>
  91. {% endif %}
  92. {% if not navbar_attributes.hasClass('container') %}
  93. </div>
  94. {% endif %}
  95. </header>
  96. {% endblock %}
  97. {% endif %}
  98. {# Main #}
  99. {% block main %}
  100. <div role="main" class="main-container {{ container }} js-quickedit-main-content">
  101. <div class="row">
  102. {# Header #}
  103. {% if page.header %}
  104. {% block header %}
  105. <div class="col-sm-12" role="heading">
  106. {{ page.header }}
  107. </div>
  108. {% endblock %}
  109. {% endif %}
  110. {# Sidebar First #}
  111. {% if page.sidebar_first %}
  112. {% block sidebar_first %}
  113. <aside class="col-sm-3" role="complementary">
  114. {{ page.sidebar_first }}
  115. </aside>
  116. {% endblock %}
  117. {% endif %}
  118. {# Content #}
  119. {%
  120. set content_classes = [
  121. page.sidebar_first and page.sidebar_second ? 'col-sm-6',
  122. page.sidebar_first and page.sidebar_second is empty ? 'col-sm-9',
  123. page.sidebar_second and page.sidebar_first is empty ? 'col-sm-9',
  124. page.sidebar_first is empty and page.sidebar_second is empty ? 'col-sm-12'
  125. ]
  126. %}
  127. <section{{ content_attributes.addClass(content_classes) }}>
  128. {# Highlighted #}
  129. {% if page.highlighted %}
  130. {% block highlighted %}
  131. <div class="highlighted">{{ page.highlighted }}</div>
  132. {% endblock %}
  133. {% endif %}
  134. {# Breadcrumbs #}
  135. {% if breadcrumb %}
  136. {% block breadcrumb %}
  137. {{ breadcrumb }}
  138. {% endblock %}
  139. {% endif %}
  140. {# Action Links #}
  141. {% if action_links %}
  142. {% block action_links %}
  143. <ul class="action-links">{{ action_links }}</ul>
  144. {% endblock %}
  145. {% endif %}
  146. {# Help #}
  147. {% if page.help %}
  148. {% block help %}
  149. {{ page.help }}
  150. {% endblock %}
  151. {% endif %}
  152. {# Content #}
  153. {% block content %}
  154. <a id="main-content"></a>
  155. {{ page.content }}
  156. {% endblock %}
  157. </section>
  158. {# Sidebar Second #}
  159. {% if page.sidebar_second %}
  160. {% block sidebar_second %}
  161. <aside class="col-sm-3" role="complementary">
  162. {{ page.sidebar_second }}
  163. </aside>
  164. {% endblock %}
  165. {% endif %}
  166. </div>
  167. </div>
  168. {% endblock %}
  169. {% if page.footer %}
  170. {% block footer %}
  171. <footer class="footer {{ container }}" role="contentinfo">
  172. {{ page.footer }}
  173. </footer>
  174. {% endblock %}
  175. {% endif %}

Related topics