Forum

Thread tagged as: Problem

Problem with multiple if exists

I’m having a problem using multiple conditions with exists. If I only use a single clause it works as expected but when using OR the condition is never met and the content does not display.

Diagnostics report
HEALTH CHECK

Perch is up to date
PHP 5.6.6 is up to date
MySQL 5.5.42 is up to date
Image processing available
SUMMARY INFORMATION

Perch: 2.8.21, PHP: 5.6.6, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $, with PDO
Server OS: Darwin, cgi-fcgi
Installed apps: content (2.8.21), assets (2.8.21), categories (2.8.21), perch_forms (1.8.3)
App runtimes: <?php include(PERCH_PATH.'/core/apps/content/runtime.php'); include(PERCH_PATH.'/core/apps/categories/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_forms/runtime.php'); ?>
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/TwoLittleFishes/Sites/antoniobosano.com/perch
PERCH_CORE: /Users/TwoLittleFishes/Sites/antoniobosano.com/perch/core
PERCH_RESFILEPATH: /Users/TwoLittleFishes/Sites/antoniobosano.com/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /Users/TwoLittleFishes/Sites/antoniobosano.com
HTTP_HOST: antoniobosano.local
<h1><perch:content id="full-name" type="text" label="Full name" html="false" required="true" /></h1>
<perch:content id="sort-name" type="text" label="Sort name" html="false" required="true" suppress="true" help="e.g. clapton-eric for Eric Clapton (makes sure that dropdown orders by last name)" />
<perch:content id="sort-date" type="text" label="Sort date" html="false" suppress="true" help="In the format yyyy-mm-dd e.g. 2013-06-12 for 12th June 2013" />
<p class="tagline">Pencil Portrait by Antonio Bosano.</p>
<figure class="portrait a2">
    <img src="<perch:content type="image" id="small-image" label="Small image" />?url=<perch:content type="image" id="large-image" label="Large image" />" class="dg-picture-zoom" alt="<perch:content type="text" id="alt" label="Image description" required="true" help="e.g. Eric Clapton Pencil Portrait" title="true" />">
    <figcaption>To see a larger preview, please click the image.</figcaption>
</figure>

<a href="//www.pinterest.com/pin/create/button/" data-pin-do="buttonBookmark" ><img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png" /></a>
<!-- Please call pinit.js only once per page -->
<script type="text/javascript" async src="//assets.pinterest.com/js/pinit.js"></script>

<perch:if exists="a2-code OR a3-code OR a4-code">
<section class="order a2">
    <h1>Shopping Basket</h1>
    <p class="quality">The quality of the prints are at a much higher level compared to the image shown above.</p>
    <h2>Order</h2>
    <perch:if exists="a2-code">
        <p class="size">A2 Pencil Print<span>-</span>Price £<perch:content id="a2-price" type="text" label="A2 Price" html="false" title="true" /><span>-</span><a href="<perch:content id="a2-code" type="text" label="A2 Paypal code" html="false" title="true" />" onClick="_gaq.push(['_trackEvent', 'Sales', 'Click', 'A2']);">Purchase</a></p>
    </perch:if>
    <perch:if exists="a3-code">
        <p class="size">A3 Pencil Print<span>-</span>Price £<perch:content id="a3-price" type="text" label="A3 Price" html="false" title="true" /><span>-</span><a href="<perch:content id="a3-code" type="text" label="A3 Paypal code" html="false" title="true" />" onClick="_gaq.push(['_trackEvent', 'Sales', 'Click', 'A3']);">Purchase</a></p>
    </perch:if>
    <perch:if exists="a4-code">
        <p class="size">A4 Pencil Print<span>-</span>Price £<perch:content id="a4-price" type="text" label="A4 Price" html="false" title="true" /><span>-</span><a href="<perch:content id="a4-code" type="text" label="A4 Paypal code" html="false" title="true" />" onClick="_gaq.push(['_trackEvent', 'Sales', 'Click', 'A4']);">Purchase</a></p>
    </perch:if>
    <p class="limited">*Limited edition run of 250 prints only*</p>
    <p class="printed">All Pencil Prints are printed on the finest Bockingford Somerset Velvet 255 gsm paper.</p>
    <p class="postage">P&P is not included in the above prices.</p>
</section>
</perch:if>

<perch:content id="second-basket" type="select" label="Repeat shopping basket at bottom?" options="No, Yes" suppress="true" />
<perch:if exists="comments">
    <section class="commentry comments">
    <h2>Comments</h2>
    <perch:content id="comments" type="textarea" label="Comments" textile="true" editor="markitup" />
    <perch:content id="summary" type="textarea" label="Summary" textile="true" editor="markitup" suppress="true" help="Short summary shown on portfolio page" />
    </section>
</perch:if>
<perch:content id="summary" type="textarea" label="Summary" textile="true" editor="markitup" suppress="true" help="Short summary shown on portfolio page" />
Nick Bramwell

Nick Bramwell 5 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The first thing that stands out is that your IDs contain dashes.

If I change them now, will that break all existing pages using that template?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, absolutely.

It looks like there are only 5 pages using the template at the moment so it shouldn’t be a huge problem to fix them all.

Thanks Drew, I’ve swapped the IDs and everything is working now.