Keyword

Don't print empty extrafield

  • STEPHAN HERBY
  • STEPHAN HERBY's Avatar Topic Author
  • Offline
  • Premium Member
More
12 years 7 months ago - 12 years 7 months ago #62887 by STEPHAN HERBY
Don't print empty extrafield was created by STEPHAN HERBY
Hi,
I have created extrafield in a div on the left of my item (as you can see on the picture joined).
Or you can see the page here :
See the page

This extrafield are called by this code :
//convertArray to use ids as key
$extrafields = array();
foreach($this->item->extra_fields as $item)
{    
$extrafields[$item->id] = $item->value;
}   
?>

<div class="itemExtraFieldscontenu">
<ul>
<li><h3>Durée</h3></li>
<li>
<span class="itemExtraFieldscontenuduree"><?php echo $extrafields[4];?></span>
</li>
<li><h3>Infos</h3></li>
<li>
<span class="itemExtraFieldscontenuvalue"><?php echo $extrafields[1];?></span>
</li>
<li><h3>On a dit...</h3></li>
<li>
<span class="itemExtraFieldscontenuvalue"><?php echo $extrafields[5];?></span>
</li>
</ul>
</div>
I would like to know how to make this extrafield invisible when they are empty. Anybody has an idea ? Thanks by advance...
Attachments:

Please Log in or Create an account to join the conversation.

More
12 years 7 months ago #62888 by william white
Replied by william white on topic Re: Don't print empty extrafield
you will need to wrap the extra field echo stament with php code to test if its empty or not
somethink like
if !($extrafields[4]="")
display it
endif

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum