kkalgidim Posted April 18, 2019 Share Posted April 18, 2019 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 More sharing options...
MoritzLost Posted April 18, 2019 Share Posted April 18, 2019 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>"; } 2 Link to comment Share on other sites More sharing options...
kkalgidim Posted April 19, 2019 Author Share Posted April 19, 2019 Thanks alot @MoritzLost Thats exactly what i am looking for. And its really super easy way. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now