2

I'm setting up an FAQ page using a matrix. Each Matrix block contains a question and an answer field. Each Q+A needs to be outputted within a section on the same page such as General, Payments...

I've figured the best way to do this is using categories to assign the Q+As section, limiting each Q+A to one category. I'd then need to output all Q+As for each section with it's category as a header.

Desired Output:

<h2>General</h2>

<p>Question field output</p>
<p>Answer field output</p>

<p>Question field output</p>
<p>Answer field output</p>

<h2>Payments</h2>

<p>Question field output</p>
<p>Answer field output</p>

....

I'm fairly new to craft so perhaps I'm overcomplicating it by assigning it to a category, it seems like it's the easiest way to add new Q+As and for them to appear within the right section.

How would I go about outputting this? I've set up a Category Group called 'faqCategories'

Here's my matrix setup:

enter image description here

3

It's tempting to use the Matrix block for things that might actually be better as a a channel or a structure. I thing this might be the case here.

The way you've set it up is fine, relating each FAQ to a category is a good approach.

In any event, the plugin groupBy should help you:

https://github.com/timkelty/groupby-craft

Or you can look at this example:

http://craftcookbook.net/recipes/279

  • Thanks. After your comment I'm now using a structure instead where each section (General, Payment..) is now an entry rather than a category, and then I have the matrix inside each entry to add as many Q+A as required. All gets outputted in my singles FAQ page. – sarah3585 Nov 22 '15 at 16:47
  • I just had another look at the groupBy plugin, but I can't figure out what it does in addition to Craft's group filter. @khalwat – carlcs Nov 23 '15 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.