Forum
Multiple Blocks in Templates
Hi, I have a simple Content template that outputs 2 columns on the front end. I want to allow the editor to choose from blocks (Text, Image, Button etc) for each column. Eg:
<div class="col-md-6">
<perch:template path="content/blocks.html" />
</div>
<div class="col-md-6">
<perch:template path="content/blocks.html" />
</div>
But I can't do this because we can't have 2 <perch:blocks>
sets in the same template.
Is multiple Blocks in Templates on the Roadmap for Perch, or does anyone have a workaround for this type of scenario? I imagine it's very common.
It's not on the roadmap currently, and it's not something we've heard of before.
You can use
perch:before
andperch:after
in blocks too.Thanks Drew, Unless I'm missing something obvious, I can't see how
perch:before
andperch:after
can help achieve my code.Simon,
If I'm understanding you correctly, can't you set your columns up as a repeater and then allow them to use the blocks?
Hi Kim,
I guess you mean 'Repeating Regions', rather than Repeaters (Blocks can't go in Repeaters). Unfortunately I'm already using the Repeating Regions to wrap the Blocks with
<section>
and<div>
.Drew, you mention using
<perch:before>
and<perch:after>
in blocks, and wanted to check if I'm missing a trick?I can't see any use for
before
andafter
in blocks at all. These two have the same effect, correct?is the same as:
Could you give an example of where
before
andafter
would be useful in blocks? It might open possibilities of helping me achieve what I need.Thanks.
No, sorry, you're right. I'm thinking of repeaters (which are all the same thing internally).