Forum

Thread tagged as: Question

Editor change output source order through template

Hi,

I am trying to allow the editor to change the output source order through an option in the content template. I am sure I am missing something obvious but I am not sure how to approach it. It's a very simple template:

<div class="container">
<div class="image">
<img src="<perch:content type="image" id="image" label="Image" width="800" />" alt="<perch:content type="text" id="alt" label="Description" required="true" help="e.g. Photo of MD John Smith with his best wig on" title="true" />" />
</div>
<div class="text">
<perch:content id="text" type="textarea" label="Text" markdown="true" editor="simplemde" />
</div>
</div>

I now want to allow the editor to choose whether in the output HTML the image comes before the text, or after. So either this:

<div class="container">
<div class="image"></div>
<div class="text"></div>
</div>

Or this:

<div class="container">
<div class="text"></div>
<div class="image"></div>
</div>

Is that possible?

Mike Harrison

Mike Harrison 37 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes,

<perch:if exists="toggle">
 <div class="text"></div> <div class="image"></div>
<perch:else />
<div class="image"></div> <div class="text"></div>
</perch:if>

Super, thanks Drew