Forum

Thread tagged as: Question, Problem

FAQs page using categories

Having trouble using Categories to create FAQs page and displaying Q &As on single page.

I have successfully created region for FAQs and have following code in my faq.html content template -


<perch:categories id="faqs" label="FAQs" set="FAQs" required="true" /> <p><span class="dark"><strong><perch:content id="question" type="text" label="Question" required="true" title="true" /></strong></span></p> <p><perch:content id="answer" type="textarea" label="Answer" markdown="true" editor="markitup" required="true" /></p> </perch:categories>

This has allowed me to add FAQs and assign them to category.

Can't get the content to display using -




perch_content_custom('FAQs', array( 'template' => 'faq.html', 'category' => 'faqs/questions/', ));

I can see the correct number of P tags so the code is correctly looping through the FAQs but not showing the question and answer text content?

Hope that makes sense.

Thanks

Keith Winter

Keith Winter 0 points

  • 6 years ago

I would also like to know please how I could loop through all categories displaying cat title and then the faqs for that cat all on the one FAQ page allowing the client to add Categories and FAQ items without me needing to manually add a region for each category?

Hope that also makes sense. Thanks again

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you try changing:

set="FAQs"

to

set="faqs"

Hi Drew. Thanks but still no joy. The odd thing is the loop is working, showing correct number of passes but just no content.

Does this code need to be inside category tag ?

<?php 
perch_content_custom('FAQs', array(
                'template' => 'faq.html',
                'category' => 'faqs/questions/',
    ));
?>

That is all I have on the page to display the content. I used a perch_content_create tag to initially set up the region.

Keith

I may have fixed it ....

changed my faq.html template to

<p><span class="dark"><strong><perch:content id="question" type="text" label="Question" required="true" title="true" /></strong></span></p>
<p><perch:content id="answer" type="textarea" label="Answer" markdown="true" editor="markitup" required="true" /></p>

from this

<perch:categories id="faqs" label="FAQs" set="faqs" required="true" />
<p><span class="dark"><strong><perch:content id="question" type="text" label="Question" required="true" title="true" /></strong></span></p>
<p><perch:content id="answer" type="textarea" label="Answer" markdown="true" editor="markitup" required="true" /></p>
</perch:categories>

I had added the perch:categories tags to enable me to assign the faqs to a category, I'm a little confused but...

My display page now has -

        <?php   
         $categories = perch_categories(array(
            'set'=>'faqs',
            'skip-template' => true
        ));


        foreach($categories as $category) {

            //show the title of the current category
           perch_category($category['catPath'],array(
               'template'=>'faq_cat_title.html'
           ));


            perch_content_custom('faqs', array(
                'template' => 'faq.html',
                'category' => $category['catPath']
            ));

        }


                ?>

Seems to be working....

Keith