Building an accordion with a Matrix field I'm trying to build an accordion in my matrix field (that also holds entries for a slideshow, button, image, etc).

Im having trouble with getting each entry to go inside &lt; div id="accordion">&lt; /div> and not repeat this accordion div over and over.

{% elseif block.type == "sectionaccordion" %}

    &lt;div id="accordion"&gt;
      {% for block in entry.sectionaccordion %}
        &lt;div class="accordiontitle"&gt;{{ block.accordionTitle }}&lt;/div&gt;
        &lt;div class="accordion-content default"&gt;
          {{ block.accordionText }}
        &lt;/div&gt;
      {% endfor %}
    &lt;/div&gt;


With this setup, I keep getting Craft\EntryModel and its behaviors do not have a method or closure named "sectionaccordion".
The error has to do with the line {% for block in entry.sectionaccordion %} because it's looking for a field in your entry called sectionaccordion but sectionaccordion is not a field; it's a block inside a field (your matrix field).  So the error is basically saying "there is no field called 'sectionaccordion' for this entry".

You also don't want to use a for loop here because there's nothing to loop through.  You're already looping through matrix blocks created in this matrix field, and your code is saying "if the block is of type sectionaccordion, print the contents of it."  The contents of that block won't be another loop; it'll only be 1 Accordion Title and 1 Accordion Text field.

Lastly, by saying {% elseif block.type == "sectionaccordion" %}, you are eliminating the chance to display a slideshow since that is a different block type, one not called sectionaccordion.  If you want a slideshow inside your accordion block type, then you need to create a 3rd field for it inside sectionaccordion and just recreate whatever you did in the sectionslideshow block type.