Skip to documentation content

FAQs Section

All complete examples

Demonstrate FAQs Section.

What this example teaches

  • Implement the FAQs Section section with its owned custom fields
  • Keep custom fields on the template that owns them

View this pattern on the live demo site

Files

Compact FAQ block included on content pages.

Liquid
{% comment %}
	Display a section containing a single short FAQ list (accordion or list)

	Inputs:
		section_class
		section_id

	Custom Fields:
		faqs - collection or list of FAQ datastore items
		faqs_title
		faqs_subtitle

	Outputs:
		section_rendered - true when this section outputs markup, false otherwise
{% endcomment -%}
{%- if entity.faqs.is_valid -%}
	<section{% if section_class %} class="{{ section_class }}"{% endif %}{% if section_id %} id="{{ section_id }}"{% endif %}>
		<div class="container">
			{%- var headinglevel = headinglevel %}{% comment %}Copy to current scope{% endcomment -%}
			{%- include "/common/_title_with_subtitle.liquid" title:entity.faqs_title subtitle:entity.faqs_subtitle postincrement_headinglevel:true -%}
			{%- include "/partials/_faqs_list.liquid" faqs: entity.faqs -%}
		</div>
	</section>
	{%- set section_rendered = true -%}
{%- else -%}
	{%- set section_rendered = false -%}
{%- endif -%}