You are here

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

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

Available variables:

  • display_answers: Whether or not there should be any output.
  • 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
  • question_label: The question label, intended to be pre-pended to the question text.
  • answer_label: The answer label, intended to be pre-pended to the answer 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_body_list: The sub-categories faqs, recursively themed (by this template).

File

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