You are here

faq-category-questions-top.html.twig in Frequently Asked Questions 8

Template file for the questions section of the FAQ page if set to show categorized questions at the top of the page.

Available variables:

  • display_header: Boolean value controlling whether a header should be displayed.
  • header_title: The category title.
  • category_name: The name of the category.
  • answer_category_name: Whether the category name should be displayed with the answers.
  • group_questions_top: Whether the questions and answers should be grouped together.
  • category_depth: The term or category depth.
  • description: The current page's description.
  • term_image: The HTML for the category image. This is empty if the taxonomy image module is not enabled or there is no image associated with the term.
  • display_faq_count: Boolean value controlling whether or not the number of faqs in a category should be displayed.
  • question_count: The number of questions in category.
  • nodes: The array of nodes to be displayed. Each node stored in the $nodes array has the following information:
    • question: The question text.
    • body: The answer text.
    • links: Represents the node links, e.g. "Read more".
  • use_teaser: Tells whether node.body contains the full body or just the teaser
  • container_class: The class attribute of the element containing the sub-categories, either 'faq-qa' or 'faq-qa-hide'. This is used by javascript to open/hide a category's faqs.
  • question_list: An array of question links.
  • question_list_style: The style of the question list, ul for unordered, ol for ordered.
  • subcat_list: An array of sub-categories. Each sub-category stored in the subcat_list array has the following information:
    • subcat.link: The link to the sub-category.
    • subcat.description: The sub-category description.
    • subcat.count: The number of questions in the sub-category.
    • subcat.term_image: The sub-category (taxonomy) image.
  • subcat_list_style: The style of the sub-category list, either ol or ul (ordered or unordered).
  • subcat_body_list: The sub-categories faqs, recursively themed (by this template).

File

templates/faq-category-questions-top.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Template file for the questions section of the FAQ page if set to show
  5. * categorized questions at the top of the page.
  6. *
  7. * Available variables:
  8. * - display_header: Boolean value controlling whether a header should be displayed.
  9. * - header_title: The category title.
  10. * - category_name: The name of the category.
  11. * - answer_category_name: Whether the category name should be displayed with the answers.
  12. * - group_questions_top: Whether the questions and answers should be grouped together.
  13. * - category_depth: The term or category depth.
  14. * - description: The current page's description.
  15. * - term_image: The HTML for the category image. This is empty if the taxonomy image module
  16. * is not enabled or there is no image associated with the term.
  17. * - display_faq_count: Boolean value controlling whether or not the number of faqs in a category should be displayed.
  18. * - question_count: The number of questions in category.
  19. * - nodes: The array of nodes to be displayed. Each node stored in the $nodes array has the following information:
  20. * - question: The question text.
  21. * - body: The answer text.
  22. * - links: Represents the node links, e.g. "Read more".
  23. * - use_teaser: Tells whether node.body contains the full body or just the teaser
  24. * - container_class: The class attribute of the element containing the sub-categories, either 'faq-qa' or 'faq-qa-hide'.
  25. * This is used by javascript to open/hide a category's faqs.
  26. * - question_list: An array of question links.
  27. * - question_list_style: The style of the question list, ul for unordered, ol for ordered.
  28. * - subcat_list: An array of sub-categories. Each sub-category stored in the subcat_list array has the following information:
  29. * - subcat.link: The link to the sub-category.
  30. * - subcat.description: The sub-category description.
  31. * - subcat.count: The number of questions in the sub-category.
  32. * - subcat.term_image: The sub-category (taxonomy) image.
  33. * - subcat_list_style: The style of the sub-category list, either ol or ul (ordered or unordered).
  34. * - subcat_body_list: The sub-categories faqs, recursively themed (by this template).
  35. *
  36. * @see template_preprocess_faq_category_questions_top()
  37. *
  38. * @ingroup themable
  39. */
  40. #}
  41. {% if category_depth > 0 %}
  42. {% set hdr = 'h4' %}
  43. {% else %}
  44. {% set hdr = 'h3' %}
  45. {% endif %}
  46. <a id="top"></a>
  47. <div class="faq-category-menu">
  48. <!-- category header with title, link, image, description, and count of questions inside -->
  49. <div class="faq-qa-header">
  50. {% if display_header %}
  51. <{{ hdr }} class="faq-header">
  52. {{ term_image }}
  53. {{ header_title }}
  54. {% if display_faq_count %}
  55. ({{ question_count }})
  56. {% endif %}
  57. </{{ hdr }}>
  58. {% else %}
  59. {{ term_image }}
  60. {% endif %}
  61. {% if description is not empty %}
  62. <div class="faq-qa-description">{{ description }}</div>
  63. {% endif %}
  64. {% if term_image is not empty %}
  65. <div class="clear-block"></div>
  66. {% endif %}
  67. </div><!-- Close div: faq-qa-header -->
  68. {% if subcat_list is not empty %}
  69. <!-- list subcategories, with title, link, description, count -->
  70. <div class="item-list">
  71. <{{ subcat_list_style }} class="faq-category-list">
  72. {% for subcat in subcat_list %}
  73. <li>
  74. {{ subcat.link }}
  75. {% if display_faq_count %}
  76. ({{ subcat.count }})
  77. {% endif %}
  78. {% if subcat.description is not empty %}
  79. <div class="faq-qa-description">{{ subcat.description }}</div>
  80. {% endif %}
  81. <div class="clear-block"></div>
  82. </li>
  83. {% endfor %}
  84. </{{ subcat_list_style }}>
  85. </div>
  86. {% endif %}
  87. <div class="{{ container_class }}">
  88. {% if subcat_body_list|length > 0 %}
  89. {% for subcat_html in subcat_body_list %}
  90. <div class="faq-category-indent">{{ subcat_html }}</div>
  91. {% endfor %}
  92. {% endif %}
  93. {# list question links #}
  94. {% if question_list is not empty %}
  95. <div class="item-list">
  96. <{{ question_list_style }} class="faq-ul-questions-top">
  97. {% for question_link in question_list %}
  98. <li>
  99. {{ question_link }}
  100. </li>
  101. {% endfor %}
  102. </{{ question_list_style }}>
  103. </div>
  104. {% endif %}
  105. {% if not group_questions_top or category_display != 'hide_qa' %}
  106. </div> <!-- Close div: faq-qa / faq-qa-hide -->
  107. </div> <!-- Close div: faq-category-menu -->
  108. {% endif %}
  109. {% if answer_category_name %}
  110. <!-- Display header before answers in some layouts. -->
  111. <{{ hdr }} class="faq-header">
  112. {{ term_image }}
  113. {{ category_name }}
  114. </{{ hdr }}>
  115. <div class="clear-block"></div>
  116. {% endif %}
  117. {# List questions (in title link) and answers (in body). #}
  118. <div class="faq-category-group">
  119. <div>
  120. {% if nodes|length > 0 %}
  121. {% for node in nodes %}
  122. <div class="faq-question">
  123. {% if question_label is not empty %}
  124. <strong class="faq-question-label">
  125. {{ question_label}}
  126. </strong>
  127. {% endif %}
  128. {{ node.question }}
  129. </div><!-- Close div: faq-question -->
  130. <div class="faq-answer">
  131. {% if answer_label is not empty %}
  132. <strong class="faq-answer-label">
  133. {{ answer_label }}
  134. </strong>
  135. {% endif %}
  136. {{ node.body }}
  137. {% if node.links is defined %}
  138. {{ node.links }}
  139. {% endif %}
  140. </div><!-- Close div: faq-answer -->
  141. {% endfor %}
  142. {% endif %}
  143. </div><!-- Close div -->
  144. </div><!-- Close div: faq-category-group -->
  145. {% if group_questions_top and category_display == 'hide_qa' %}
  146. </div> <!-- Close div: faq-qa / faq-qa-hide -->
  147. </div> <!-- Close div: faq-category-menu -->
  148. {% endif %}