Jump to content
kkalgidim

Dynamic Faq page from content section of admin

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?

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...