Forum

Thread tagged as: Question

Nested blocks

How can I achieve to have within a «perch:block» that is already located in «perch:blocks» again 2 «perch:block»s? I think repeaters do not really match what I want to do. I would prefer that the editor can choose what he wants to insert, an image or a movie. By default there shouldn't nothing be inserted yet, just like it is the case on the first level (year or news). Thanks a lot!


<perch:blocks> <perch:block type="year" label="year"> <!—- Some content -—> </perch:block> <perch:block type="news" label="news entry"> <!—- Here I want again to be able to choose from 2 blocks (Image or Movie) -—> </perch:block> </perch:blocks>
Martin Stettler

Martin Stettler 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

No, you can't nest blocks I"m afraid.

Ok, thanks. So I would like to ask you how you would develop the following: there is a page with two different articles (blocks) that can be put in. One (media) should have two options of elements that can put in as many times as required. Here's my latest code:


<perch:blocks> <perch:block type="year" label="year"> <perch:content … /> </perch:block> <perch:block type="news" label="news"> <div class="col-sm-5"> <perch:repeater id="media" label="media"> <perch:if exists="image"> <img src="<perch:content … /> </perch:if> <perch:if exists="movie"> <perch:content …/> </perch:if> </perch:repeater> </div> <div class="col-sm-5"> <perch:content …/> </div> </perch:block> </perch:blocks>

Thanks!

Has this question been answered somewhere else? I have the same requirement.