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

Related topics