You are here

faq-category-hide-answer.html.twig in Frequently Asked Questions 8

Template file for the FAQ page if set to show/hide categorized answers when the question is clicked.

Available variables:

  • display_header: Boolean value controlling whether a header should be displayed.
  • header_title: The category title.
  • 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: An 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: Whether node.body contains the full body or just the teaser text.
  • 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.
  • subcat_list: An array of sub-categories. Each sub-category stored in the $subcat_list array has the following information:

    • link: The link to the sub-category.
    • description: The sub-category description.
    • count: The number of questions in the sub-category.
    • 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-hide-answer.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Template file for the FAQ page if set to show/hide categorized answers when
  5. * the question is clicked.
  6. *
  7. * Available variables:
  8. * - display_header: Boolean value controlling whether a header should be displayed.
  9. * - header_title: The category title.
  10. * - category_depth: The term or category depth.
  11. * - description: The current page's description.
  12. * - term_image: The HTML for the category image. This is empty if the taxonomy image module
  13. * is not enabled or there is no image associated with the term.
  14. * - display_faq_count: Boolean value controlling whether or not the number of faqs in a category
  15. * should be displayed.
  16. * - question_count: The number of questions in category.
  17. * - nodes: An array of nodes to be displayed.
  18. * Each node stored in the $nodes array has the following information
  19. * - question: The question text.
  20. * - body: The answer text.
  21. * - links: Represents the node links, e.g. "Read more".
  22. * - use_teaser: Whether node.body contains the full body or just the teaser text.
  23. * - container_class: The class attribute of the element containing the sub-categories, either
  24. * 'faq-qa' or 'faq-qa-hide'. This is used by javascript to open/hide
  25. * a category's faqs.
  26. * - subcat_list: An array of sub-categories. Each sub-category stored in the $subcat_list
  27. * array has the following information:
  28. * - link: The link to the sub-category.
  29. * - description: The sub-category description.
  30. * - count: The number of questions in the sub-category.
  31. * - term_image: The sub-category (taxonomy) image.
  32. * - subcat_list_style: The style of the sub-category list, either ol or ul (ordered or unordered).
  33. * - subcat_body_list: The sub-categories faqs, recursively themed (by this template).
  34. *
  35. * @see template_preprocess_faq_category_hide_answer()
  36. *
  37. * @ingroup themable
  38. */
  39. #}
  40. {% if category_depth > 0 %}
  41. {% set hdr = 'h4' %}
  42. {% else %}
  43. {% set hdr = 'h3' %}
  44. {% endif %}
  45. <div class="faq-category-group">
  46. <!-- category header with title, link, image, description, and count of questions inside -->
  47. <div class="faq-qa-header">
  48. {% if display_header %}
  49. <{{ hdr }} class="faq-header">
  50. {{ term_image }}
  51. {{ header_title }}
  52. {% if display_faq_count %}
  53. ({{ question_count }})
  54. {% endif %}
  55. </{{ hdr }}>
  56. {% else %}
  57. {{ term_image }}
  58. {% endif %}
  59. {% if description is not empty %}
  60. <div class="faq-qa-description">{{ description }}</div>
  61. {% endif %}
  62. {% if term_image is not empty %}
  63. <div class="clear-block"></div>
  64. {% endif %}
  65. </div><!-- Close div: faq-qa-header -->
  66. {% if subcat_list is not empty %}
  67. <!-- list subcategories, with title, link, description, count -->
  68. <div class="item-list">
  69. <{{ subcat_list_style }} class="faq-category-list">
  70. {% for subcat in subcat_list %}
  71. <li>
  72. {{ subcat.link }}
  73. {% if display_faq_count %}
  74. ({{ subcat.count }})
  75. {% endif %}
  76. {% if subcat.description is not empty %}
  77. <div class="faq-qa-description">{{ subcat.description }}</div>
  78. {% endif %}
  79. <div class="clear-block"></div>
  80. </li>
  81. {% endfor %}
  82. </{{ subcat_list_style }}>
  83. </div><!-- Close div: item-list -->
  84. {% endif %}
  85. <div class="{{ container_class }}">
  86. <!-- include subcategories -->
  87. {% if subcat_body_list|length > 0 %}
  88. {% for subcat_html in subcat_body_list %}
  89. <div class="faq-category-indent">{{ subcat_html }}</div>
  90. {% endfor %}
  91. {% endif %}
  92. <!-- list questions (in title link) and answers (in body) -->
  93. <div class="faq-dl-hide-answer">
  94. {% if nodes|length > 0 %}
  95. {% for node in nodes %}
  96. <div class="faq-question-answer">
  97. <div class="faq-question faq-dt-hide-answer">
  98. {{ node.question }}
  99. </div><!-- Close div: faq-question faq-dt-hide-answer -->
  100. <div class="faq-answer faq-dd-hide-answer">
  101. {{ node.body }}
  102. {% if node.links is defined %}
  103. {{ node.links }}
  104. {% endif %}
  105. </div><!-- Close div: faq-answer faq-dd-hide-answer -->
  106. </div><!-- Close div: faq-question-answer -->
  107. {% endfor %}
  108. {% endif %}
  109. </div><!-- Close div: faq-dl-hide-answer -->
  110. </div><!-- Close div: faq-qa / faq-qa-hide -->
  111. </div><!-- Close div: faq-category-group -->