Jump to content

Dynamic Faq page from content section of admin


kkalgidim
 Share

Recommended Posts

Hi again,

This time i am trying to implement a faq section for treatments.

Every treatment has its own question Answer section.

Treatments

  • Dental Implant
  • Hair Transplant

FAQ

  • Sample Question 1 
  • Sample Question 2

faq template has question and answer fields

I can use page reference field for Faq but on the Treatment template when i hit new Faq button it only creates new question.

So i should go back to question under FAQ category  and edit it then fill answer field. 

 

What  i want is  when i click on new faq button. i should fill question and answer fileds to gether ?

Or any other way to do this instead of page refrence?

 

Link to comment
Share on other sites

If each FAQ item belongs to one treatment only, I would use a Repeater instead of a page reference, so that the questions and answers can be edited in one place, on the same page where you edit the treatment itself. The repeater field is bundled in the core, but isn't active by default (go to Modules -> Core to install it).

In this case, you would create a Repeater field faq containing two text fields question and answer (for example). Then you can loop over the repeater items in your frontend template and display them:

foreach ($page->faq as $faq_item) {
	echo "<details><summary>{$faq_item->question}</summary>{$faq_item->answer}</details>";
}

 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...