Jump to content

[Pages] Database registration field


Recommended Posts

Hello,

On a personalize display, what is the solution so that empty fields without data are not displayed on the page?

My current code which even displays the fields when there is no data

<article class='ipsContained ipsResponsive_pull'>
	<div class='ipsClearfix'>
      <h1 class="ipsType_pageTitle ipsContained_container"><i class="fa fa-info-circle" aria-hidden="true"></i> Présentation</h1>
      <hr class="ipsHr">  
      {$record->customFieldDisplayByKey('date-fabrication', 'display')|raw}<br><br>
      {$record->customFieldDisplayByKey('propriétaire', 'display')|raw}<br>
      {$record->customFieldDisplayByKey('statut', 'display')|raw}<br>
      {$record->customFieldDisplayByKey('constructeur', 'display')|raw}<br> 
      {$record->customFieldDisplayByKey('Peintre', 'display')|raw}<br>
      {$record->customFieldDisplayByKey('modèle', 'display')|raw}<br><br>
	  {$record->customFieldDisplayByKey('sitewebpb', 'display')|raw}<br>
      {$record->customFieldDisplayByKey('réseau-socialpb', 'display')|raw}
      <hr class="ipsHr">
 </div>
  </article>

Thank you for your help.

Edited by emeric73
Link to comment
Share on other sites

Normally, you would wrap it in an IF query: {{if $variable}}{$variable}{{endif}}
This can still cause problems with some fiel types, since they can return something even if nothing was added to the field. 

The better solution is to define the output in the field settings itself. There you can check for content like this:
{{if $formValue}}{$value}{{endif}}

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

Thanks for your feedback. This type of request is not possible to be directly to the model?

When I use it directly in the field parameter it works but keeps the line breaks on the display.
 

{{if $formValue}}<span class="ipsBadge ipsBadge_large ipsBadge_style12"><i class="fa fa-arrows-h" aria-hidden="true"></i>  {$label} :</span><span class="ipsBadge_large"> {$value}</span>{{endif}}

 

I'm stupid I must delete but line break and add them directly to the field parameter. Thanks again for your help.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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