node--recipe--full.html.twig

Theme override to display a recipe in the 'full' view mode.

The recipe design places the fields into a one-plus-four grid (the image alongside the four badges) and a narrow/wide pair (ingredients alongside the instructions), and closes with the related recipes listing.

Available variables:

  • node: The node entity with limited access to object properties and methods. Only method names starting with "get", "has", or "is" and a few common methods such as "id", "label", and "bundle" are available. For example:

    • node.getCreatedTime() will return the node creation timestamp.
    • node.hasField('field_example') returns TRUE if the node bundle includes field_example. (This does not indicate the presence of a value in this field.)
    • node.isPublished() will return whether the node is published or not.

    Calling other methods, such as node.delete(), will result in an exception. See \Drupal\node\Entity\Node for a full list of public properties and methods for the node object.

  • label: (optional) The title of the node.
  • content: All node items. Use {{ content }} to print them all, or print a subset such as {{ content.field_example }}. Use {{ content|without('field_example') }} to temporarily suppress the printing of a given child element.
  • author_picture: The node author user entity, rendered using the "compact" view mode.
  • metadata: Metadata for this node.
  • date: (optional) Themed creation date field.
  • author_name: (optional) Themed author name field.
  • url: Direct URL of the current node.
  • display_submitted: Whether submission information should be displayed.
  • attributes: HTML attributes for the containing element.
  • title_attributes: Same as attributes, except applied to the main title tag that appears in the template.
  • content_attributes: Same as attributes, except applied to the main content tag that appears in the template.
  • author_attributes: Same as attributes, except applied to the author of the node tag that appears in the template.
  • title_prefix: Additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • title_suffix: Additional output populated by modules, intended to be displayed after the main title tag that appears in the template.
  • related_recipes: Listing of recipes sharing this recipe's category. Only set when there is something to list.
  • related_recipes_title: Heading for that listing.
  • view_mode: View mode; for example, "teaser" or "full".
  • page: Flag for the full page state. Will be true if view_mode is 'full'.
  • logged_in: Flag for authenticated user status. Will be true when the current user is a logged-in member.
  • is_admin: Flag for admin user status. Will be true when the current user is an administrator.

See also

template_preprocess_node()

File

core/profiles/demo_umami/themes/umami/templates/content/node--recipe--full.html.twig

View source
  1. {#
  2. /**
  3. * @file
  4. * Theme override to display a recipe in the 'full' view mode.
  5. *
  6. * The recipe design places the fields into a one-plus-four grid (the image
  7. * alongside the four badges) and a narrow/wide pair (ingredients alongside the
  8. * instructions), and closes with the related recipes listing.
  9. *
  10. * Available variables:
  11. * - node: The node entity with limited access to object properties and methods.
  12. * Only method names starting with "get", "has", or "is" and a few common
  13. * methods such as "id", "label", and "bundle" are available. For example:
  14. * - node.getCreatedTime() will return the node creation timestamp.
  15. * - node.hasField('field_example') returns TRUE if the node bundle includes
  16. * field_example. (This does not indicate the presence of a value in this
  17. * field.)
  18. * - node.isPublished() will return whether the node is published or not.
  19. * Calling other methods, such as node.delete(), will result in an exception.
  20. * See \Drupal\node\Entity\Node for a full list of public properties and
  21. * methods for the node object.
  22. * - label: (optional) The title of the node.
  23. * - content: All node items. Use {{ content }} to print them all,
  24. * or print a subset such as {{ content.field_example }}. Use
  25. * {{ content|without('field_example') }} to temporarily suppress the printing
  26. * of a given child element.
  27. * - author_picture: The node author user entity, rendered using the "compact"
  28. * view mode.
  29. * - metadata: Metadata for this node.
  30. * - date: (optional) Themed creation date field.
  31. * - author_name: (optional) Themed author name field.
  32. * - url: Direct URL of the current node.
  33. * - display_submitted: Whether submission information should be displayed.
  34. * - attributes: HTML attributes for the containing element.
  35. * - title_attributes: Same as attributes, except applied to the main title
  36. * tag that appears in the template.
  37. * - content_attributes: Same as attributes, except applied to the main
  38. * content tag that appears in the template.
  39. * - author_attributes: Same as attributes, except applied to the author of
  40. * the node tag that appears in the template.
  41. * - title_prefix: Additional output populated by modules, intended to be
  42. * displayed in front of the main title tag that appears in the template.
  43. * - title_suffix: Additional output populated by modules, intended to be
  44. * displayed after the main title tag that appears in the template.
  45. * - related_recipes: Listing of recipes sharing this recipe's category. Only
  46. * set when there is something to list.
  47. * - related_recipes_title: Heading for that listing.
  48. * - view_mode: View mode; for example, "teaser" or "full".
  49. * - page: Flag for the full page state. Will be true if view_mode is 'full'.
  50. * - logged_in: Flag for authenticated user status. Will be true when the
  51. * current user is a logged-in member.
  52. * - is_admin: Flag for admin user status. Will be true when the current user
  53. * is an administrator.
  54. *
  55. * @see template_preprocess_node()
  56. */
  57. #}
  58. {%
  59. set classes = [
  60. 'node',
  61. 'node--type-' ~ node.bundle|clean_class,
  62. node.isPromoted() ? 'node--promoted',
  63. node.isSticky() ? 'node--sticky',
  64. not node.isPublished() ? 'node--unpublished',
  65. view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
  66. ]
  67. %}
  68. {% set created_date = node.getCreatedTime|format_date('umami_dates') %}
  69. {{ attach_library('umami/classy.node') }}
  70. <article{{ attributes.addClass(classes) }}>
  71. {{ title_prefix }}
  72. {% if label %}
  73. <header class="node__header">
  74. <h1 class="page-title">
  75. {{ label }}
  76. </h1>
  77. </header>
  78. {% endif %}
  79. {{ title_suffix }}
  80. {% if display_submitted %}
  81. <footer class="node__meta">
  82. <div{{ author_attributes.addClass('node__submitted') }}>
  83. {% trans %}<span class="by-author">by {{ author_name }}</span> {{ created_date }}{% endtrans %}
  84. {{ metadata }}
  85. </div>
  86. </footer>
  87. {% endif %}
  88. <div{{ content_attributes.addClass('node__content') }}>
  89. {{ content.field_recipe_category }}
  90. {{ content.field_tags }}
  91. {{ content.field_summary }}
  92. <div class="recipe__overview">
  93. <div class="recipe__overview-media">
  94. {{ content.field_media_image }}
  95. </div>
  96. <div class="recipe__badges">
  97. <div class="recipe__badge">
  98. {{ content.field_preparation_time }}
  99. </div>
  100. <div class="recipe__badge">
  101. {{ content.field_cooking_time }}
  102. </div>
  103. <div class="recipe__badge">
  104. {{ content.field_number_of_servings }}
  105. </div>
  106. <div class="recipe__badge">
  107. {{ content.field_difficulty }}
  108. </div>
  109. </div>
  110. </div>
  111. <div class="recipe__detail">
  112. <div class="recipe__ingredients">
  113. {{ content.field_ingredients }}
  114. </div>
  115. <div class="recipe__instructions">
  116. {{ content.field_recipe_instruction }}
  117. </div>
  118. </div>
  119. {# Anything the display shows that is not placed above, such as the content
  120. moderation control. #}
  121. {{ content|without(
  122. 'field_recipe_category',
  123. 'field_tags',
  124. 'field_summary',
  125. 'field_media_image',
  126. 'field_preparation_time',
  127. 'field_cooking_time',
  128. 'field_number_of_servings',
  129. 'field_difficulty',
  130. 'field_ingredients',
  131. 'field_recipe_instruction',
  132. ) }}
  133. {% if related_recipes %}
  134. <div class="recipe__related">
  135. <h2 class="recipe__related-title">{{ related_recipes_title }}</h2>
  136. {{ related_recipes }}
  137. </div>
  138. {% endif %}
  139. </div>
  140. </article>

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.