Hello!
I am trying to do something similar to this post: http://www.interactivetools.com/forum/forum-posts.php?postNum=2217470#post2217470
Unfortunately, I can't seem to make this work and am reaching out for help to save my sanity. :-)
Essentially, I am trying to arrange FAQ questions and answers underneath their respective category heading. So, when working, it should appear like this.
Category 1
- Question 1
Answer 1
- Question 3
Answer 3
Category 2
- Question 2
Answer 2
- Question 5
Answer 5
Category 3
- Question 4
Answer 4
- Question 6
Answer 6
For this example, in CMSB, I have a multi editor where the client add questions (faq_questions) and they can select a category radio button which is supplied by a category multi-editor (faq_topics).
My full implementation will include toggles for each question, as seen here: http://dwellingproductions.com/clients/cvrs/faq.php
But, for now, I've pared down the code to try and get it working before I add the toggle code. You can see my "progress" here: http://dwellingproductions.com/clients/cvrs/faq2.php Right now, the topic headings display, but no questions and answers display.
The code I currently have is:
<?php $questionsByTopic = array_groupBy($faq_questionsRecords, 'topic', true); ?>
<?php foreach (getListOptions('faq_questions', 'topic') as $value => $label): ?>
<h4><?php echo $label;?></h4>
<?php $faq_questions['topic'] = @$questionsByTopic[$value]; ?>
<?php if (!$faq_questions) { $faq_questions = array(); } ?>
<?php foreach ($faq_questions as $record): ?>
<p>
<?php echo $record['question'] ?><br>
<?php echo $record['answer'] ?><br><br>
</p>
<?php endforeach ?>
<?php endforeach ?>
It would also be nice if the category (topic) heading would not display if there were no questions associated with it (as shown in this post: http://www.interactivetools.com/forum/forum-posts.php?postNum=2217490#post2217490). I left that code out for now because it wouldn't display anything when I added it. :-)
In case they are needed, the field names I'm working with are:
For Categories: faq_topics: 'title'
For FAQ Items: faq_questions: 'question', 'answer', 'topic' (the list which pulls topic titles from the above 'faq_topics")
Hopefully that all makes sense. Thanks, in advance, for any assistance!
- Jeremy
---------------------------
Dwelling Productions
www.dwellingproductions.com