Forum

Thread tagged as: Question, Problem

Problem with if else content

Hi Drew/Rachel,

I have the below template assigned to a standard Perch content region with allow multiple items set to true. The idea is to display a table of items (if there are any) or display a message if there are no items. If I add an item, I see the table and the rest of the markup but when I delete the item no table is displayed but neither is the message. The only way to show the message is to save the region under region options.

<perch:if exists="type">

<perch:before>
    <table class="table table-striped">
  <tr>
    <th scope="col">One</th>
    <th scope="col">Two</th>
    <th scope="col">Three</th>
    <th scope="col">Four</th>
  </tr>
</perch:before>

  <tr>
    <td><perch:content id="a" type="text" label="A" required="true" /></td>
    <td><perch:content id="b" type="text" label="B" required="true" /></td>
    <td><perch:content id="c" type="text" label="C" required="true" /></td>
    <td><perch:content id="d" type="text" label="D" required="true" /></td>
  </tr>
  <tr>
    <td colspan="4">Date <perch:content id="e" type="date" format="l jS F Y" label="E" required="true" /></td>
  </tr>

<perch:after>
    </table>

    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>

    <ul class="download">
        <li><a href="downloads/aaa.pdf">AAA</a></li>
        <li><a href="downloads/bbb.pdf">BBB</a></li>
    </ul>
</perch:after>

<perch:else />

No items to display

</perch:if>
Andy Knight

Andy Knight 1 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Hi Drew,

I have just tried this replacing my template code with the example from the link above. I am still not seeing the no results message on the page.

<perch:before>
<ul>
</perch:before>
    <li><perch:content id="item" type="text" label="Item" /></li>
<perch:after>
</ul>
</perch:after>
<perch:noresults>
    Sorry, there are no items currently available.
</perch:noresults>

Got it working - needs perch_content_custom