We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Problem

Multiple `blocks` tags

I'm building a template which has 3 distinct sections inside it: problem > solution > results. Each of these sections has a heading and a bit of text. I'd like for there to be the option of an image or images too, so I reckon blocks is the answer.

The only problem is that all the blocks are being output in the same place in the Perch control panel. Specifically, where the first blocks tag pair is declared in the template.

On the page itself, only the first block added is output to the page.

I'm guessing there's something happening with more than one blocks tag pair… I've tried adding id to each of the blocks tags but that didn't work. Nothing in the docs that I can spot either. Is only one set of blocks per template the limit?

Here's my code so you can get a better idea of what I'm babbling on about :)

  <h2><span class="qualifier">Understanding the challenge</span><perch:content id="challenge_heading" label="Section heading" divider-before="Understanding the challenge" /></h2>
  <perch:content id="challenge_text" type="textarea" label="Text" markdown="true" required="true" editor="markitup" size="m" />
  <perch:blocks>
    <perch:block label="One image" type="challenge_one_image">
      <perch:template path="content/blocks/one_image.html" />
    </perch:block>
    <perch:block label="Two images" type="challenge_two_images">
      <perch:template path="content/blocks/two_images.html" />
    </perch:block>
    <perch:block label="Three images" type="challenge_three_images">
      <perch:template path="content/blocks/three_images.html" />
    </perch:block>
    <perch:block label="Text" type="text">
      <perch:content id="text" type="textarea" label="Text" markdown="true" editor="markitup" />
    </perch:block>
  </perch:blocks>

  <h2><span class="qualifier">Our solution</span> <perch:content id="solution_heading" label="Section heading" divider-before="Our solution" /></h2>
  <perch:content id="solution_text" type="textarea" label="Text" markdown="true" required="true" editor="markitup" size="m" />
  <perch:blocks>
    <perch:block label="One image" type="solution_one_image">
      <perch:template path="content/blocks/one_image.html" />
    </perch:block>
    <perch:block label="Two images" type="solution_two_images">
      <perch:template path="content/blocks/two_images.html" />
    </perch:block>
    <perch:block label="Three images" type="solution_three_images">
      <perch:template path="content/blocks/three_images.html" />
    </perch:block>
    <perch:block label="Text" type="text">
      <perch:content id="text" type="textarea" label="Text" markdown="true" editor="markitup" />
    </perch:block>
  </perch:blocks>

  <h2><span class="qualifier">The results</span><perch:content id="results_heading" label="Section heading" divider-before="The results" /></h2>
  <perch:content id="results_text" type="textarea" label="Text" markdown="true" required="true" editor="markitup" size="m" />
  <perch:blocks>
    <perch:block label="One image" type="results_one_image">
      <perch:template path="content/blocks/one_image.html" />
    </perch:block>
    <perch:block label="Two images" type="results_two_images">
      <perch:template path="content/blocks/two_images.html" />
    </perch:block>
    <perch:block label="Three images" type="results_three_images">
      <perch:template path="content/blocks/three_images.html" />
    </perch:block>
    <perch:block label="Text" type="text">
      <perch:content id="text" type="textarea" label="Text" markdown="true" editor="markitup" />
    </perch:block>
  </perch:blocks>
Martin Underhill

Martin Underhill 5 points

  • 3 years ago
Duncan Revell

Duncan Revell 78 points
Registered Developer

Hi Martin,

The Blocks documentation does contain the following:

A blocked section can include as many blocks as needed. A template can only contain one perch:blocks section

Hi Duncan, I totally missed that. Thanks for keeping me right :)

Duncan Revell

Duncan Revell 78 points
Registered Developer

No worries - I didn't have time to try, but I would guess that using template includes probably wouldn't get round the issue, not sure if it's worth trying...