Jump to content

[Pages] How do you test if a field is empty ?

Featured Replies

Posted

Hello,

In the records templates, I need to hide a field if it's empty.
Before the 4.0, it was possible to do that :

<if test="$data['record']['field_17']">{$data['record']['field_17']}</if>

Since the 4.0, this doesn't work.
I tried this without success : 

  <if test="{customFieldDisplayByKey('field_17')">

 

 

So, how to hide a field, if it's empty, please ?

 

 

  • Author

I'm sorry for that up', but I need an answer and it will be useful for other members, anyway.

 

I tried this, also :

 <if test="{$record->customFieldDisplayByKey('field_16')|raw}">  </if>

It doesn't work, neither.

 

Odd. If one of my fields has no data then it isn't displayed by default.

Can you link the page?

  • Author

Ah... The fact is that I don't use the default template.
Instead, I display each field like that, to get my own view :

{$record->customFieldDisplayByKey('field_1')|raw}

Thank you for your reply, by the way.

  • Author

Eh eh, I think I have found the solution, by doing something like that :

	{{if $fieldValue}}{$record->customFieldDisplayByKey('field_1')|raw} 
<div class="contenu">
  	<h2 align="center" class=' ipsType_sectionTitle ipsType_reset ipsType_blendLinks'>
    Bibliographie
      </h2>
    
  <br>
   {$record->customFieldDisplayByKey('field_2')|raw}
   {{endif}}

 

 

**edit**

No, this is unperfect, because the first $record-> is not only evaluated, but also displayed :(

  • Author

There is probably something to do with that line :

{{foreach $record->customFieldsForDisplay('display') as $fieldId => $fieldValue}}

But what's the good grammar... ?

Archived

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

Recently Browsing 0

  • No registered users viewing this page.