Frequently asked questions as an accordion
Five questions and answers that open on click.
Life cycle: Build, example 14 of 35. Worked out on the Fit & Healthy site of Exponential 6.0.15+.
Contents
In the Layouts editor
- Open Layouts > Layouts and the layout Landing Page / Home; the editor opens it in a draft.
- Open the block palette (+ at the top left) and drag Accordion (group Basic) into the zone
main. - Select the block, open the Design tab and fill Items (Title|Content per line), one question per line as
Question|Answer, and Open first item. - Publish layout. The pages that use the layout show the block on their next view.
When the questions are content items (for example the class Accordion item), use Accordion (List) (group Listing) with a collection instead.
With templates
- Fetch the questions as content and print them with
<details>:
def $faq = fetch( 'content', 'list', hash( 'parent_node_id', <folder node id>, 'class_filter_type', 'include', 'class_filter_array', array( 'ng_accordion_item' ) ) )
foreach $faq as $q
<details><summary>$q.name|wash</summary>attribute_view_gui attribute=$q.data_map.description</details>
/foreach
undef $faqThe class Accordion item (ng_accordion_item) has the fields title and description.
Which to choose
A few questions on one page: the Accordion block. Many questions reused on several pages: content items and a list.
Check
- Each question opens and closes with the keyboard too.
Related pages
- Manual and dynamic collections
- Build examples, every page
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.