Forum

Thread tagged as: Problem, Field-Types, Question

Sets of accordion-style content on one page

I have a simple site structure, and on one page I have 3 columns with an 'accordion' list in each - the title is clicked and the paragraph expands/collapses underneath.

So in each column I've got (for example col 1 below):

<?php
    perch_content_create('How We Work – Accordions', array(
      'template' => 'accordion.html',
      'multiple' => 'true',
      'filter' => 'section',
      'match' => 'eq',
      'value' => 'Strategy'
    ));
?>

And then my template:

<div class="accordionholder" data-ix="accordion-openclose">
    <div class="accordionplus">+</div>
    <div class="accordionminus" data-ix="start-invisible">–</div>
    <div class="accordiontitle"><perch:content id="accordion-title" label="Title" type="text" /></div>
    <div class="accordionexpandingpanel" data-ix="accordionpanel-start-hidden">
        <p class="standardpara"><perch:content id="accordion-para" label="Paragraph" type="textarea" editor="redactor" html="true" /></p>
    </div>
    <perch:content id="section" label="Section" help="Choose the suitable column" type="select" options="Strategy, Sustainable Supply, Environment" required="true" />
</div>

...with the idea being that, similar to blog posts, I can show all items in their appropriate column, according to their 'section' value. I've got a load of items entered in the appropriate region.

Unsurprisingly to likely anyone who knows what they're doing with Perch, this doesn't work. My understanding of the CMS structure (or the API) is stumbling a little here, how can I achieve what I'm trying to do? Am I even close?

Oliver Skinner

Oliver Skinner 0 points

  • 4 years ago

I've made some progress - as per the docs

you must create the region before it is used on the page. Practically, that means putting your perch_content_create() statements at the top of the page.

Which I've now done... and then calling perch_content_custom in the subsequent columns. Some styling issues to fix but the principle is working.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok - let us know if we can help!