Forum
How to use two seperate blocks in one region
I'm currently providing the user the option to create for a cv and an image:
2010 did this |
2011 did that | IMAGE GOES
2012 did another thingy | HERE
2015 still rocking |
Now I'd like to provide the user with anther option to add multiple exhibitions below:
2010 did this |
2011 did that | IMAGE GOES
2012 did another thingy | HERE
2015 still rocking |
==============================
Exhibition 1
* 2009
* Stonehenge
* Cool Copy
Exhibition 2
* 2010
* Asterix
* Cool Copy
Exhibition 3
* 2012
* Obelix
* Cool Copy
My template looks like this:
<section id='<perch:content id="pageslug" type="hidden" />' xmlns:perch="https://www.w3.org/1999/html">
<div class="sectionTitle">
<h1>
<perch:content id="pageTitle" type="hidden"/>
</h1>
</div>
<div class="container" id='content-<perch:content id="pageslug" type="hidden" />'>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<table class="table biographie">
<tbody>
<perch:blocks>
<perch:block type="zeitpunkt" label="Lebenslauf Eintrag hinzufügen">
<tr>
<td>
<perch:content id="cvtime" type="text" label="Jahr / Zeitraum" />
</td>
<td>
<perch:content id="cvtext" type="textarea" label="Was getan wurde" editor="markitup" markdown="true" size="s" />
</td>
</tr>
</perch:block>
</perch:blocks>
</tbody>
</table>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<img src='<perch:content id="cvimage" label="Bild" type="image" />'
alt='<perch:content id="bildtitel" label="Bild Titel" type="text" />'
width="100%"/>
<legend>
<perch:content type="text" id="legend" label="Bildunterschrift"/>
</legend>
</div>
</div>
<div class="exhibitions">
<!-- here, I'd like to generate the list of exhibitions -->
</div>
</div>
</section>
The user should have three sections to edit in the backend:
- the list of CV entries
- the image
- the list of exhibitions
With the current layout/design, the CV list and the exhibitiuon list are mutually exclusive, i.e. you should not be able to put a cv line into the exhibitions list and vice versa.
As I cannot simply add another <perch:blocks>
structure, how should I approach this?
Should the exhibitions not be a region of their own?
You could use a repeater, like this:
The problem is that the regions for each are singular and auto generated.
The index.php file has this code to generate the regions:
Then, the pages themself will be put into the page with this code:
~~~
~~
By using this approach, I limited myself to only one region per page (
Inhalt
) unless I intruduce additional qirks in the pages loop (if ($slug=='biography')
), or maybe add another 'dummy' region to each page wich then would be left empty for all other pages. Each of these solutions/workaronds is adding too much complexity and clumsiness for my taste.As this is my first encounter with perch, I might have overlooked a relevant feature, so any other approach on how to build a one-pager using multiple perch pages is welcome, too ;)
@ Simon Clay What would be the dummy explanation on the difference between blocks and repeaters?
Blocks will allow an editor to choose different types of content to add i.e.:
Repeaters are for just a fixed set of fields that get repeated.
Thanx Simon!
That's good intel, so I will convert my blocks to a repeater and simply use another repeater for the exhibitions.
ouch, I wanted to select Simons first answer as solution, can the mod help here?