Jump to content

Pages DB Template Show Field if Set


BN_IT_Support

Recommended Posts

What's wrong with this please?

{{if $record->customFieldDisplayByKey('offer_title')}}
  <span class='ipsType_light ipsType_reset ipsType_large'>
    <a href="{$record->container()->url()}" title="Country"> <i class="fa fa-globe" aria-hidden="true"></i> {$record->container()->_title}</a>
  </span>
{{endif}}

I'm trying to display a DB field in a DB template only if the field has a value.  But this displays all the time irrespective of whether there is anything in 'offer_title'.

Link to comment
Share on other sites

Try the specific template call, like so:

{{if $record->customFieldsForDisplay('display')['your_field_name']}}

{{endif}}

That should work for text fields. 

 

(My preferred method is to move the the check into the field settings and check for $formValue. That works for more field types.)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...