-3

I´m adding extra fields in Joomla articles, and I want to not show that new fields (and "li") if there are empty:

From this

<ul>
  <li>
      <?php echo $this->item->direccion; ?>  
      <a href="<?php echo  $this->item->urlMap; ?>" target="<?php echo $this->item->targetMap; ?>">Mapa</a>
   </li>
</ul>

To something like this:

 <ul>
   <li "if MOLA is empty not show this li">
      <?php echo $this->item->MOLA; ?>  
      <a href="<?php echo  $this->item->urlMap; ?>" target="<?php echo $this->item->targetMap; ?>">Map</a>
   </li>
 </ul>
4

1 回答 1

3

您可以在您之前使用if条件<li></li>并检查变量是否不是empty

 <ul>
   <?php if(!empty($this->item->MOLA)) { ?>      
   <li>
      <?php echo $this->item->MOLA; ?>  
      <a href="<?php echo  $this->item->urlMap; ?>" target="<?php echo $this->item->targetMap; ?>">Map</a>
   </li>
   <?php } ?> 
 </ul>
于 2013-05-17T07:46:37.090 回答