Forum

Thread tagged as: Problem

If Exists problem

Hi,

I can't figure out why the following If Exists code isn't working.


<perch:if exists id="portcustname"> <section class="content2 sections"> <div class="container"> <div class="row"> <div class="span12"> <h2>What the customer said</h2> <perch:content id="portquote" type="textarea" html="true" editor="ckeditor" label="Customer Quote" help="Text for the Customer quote section" /> <p><perch:content id="portcustname" type="text" label="Customer Name and Location" help="enter as 'J. Bloggs, Chandlers Ford, Hampshire' etc" /></p> </div><!--row end --> </div> </div> </section> </perch:if>

I am still seeing the whole section on the web page even though the portcustname is empty.

Any clues?

Neil Duddridge

Neil Duddridge 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It isn't working because you've made up your own syntax :)

See the documentation and top example here: https://docs.grabaperch.com/docs/templates/conditionals/if/

Should be:

<perch:if exists="portcustname">

:D Doh! I've used if exist many times before, how did I not spot that. I shouldn't code late at night.