Keyword

Hide Empty Row

  • nestor
  • nestor's Avatar Topic Author
  • Offline
  • New Member
More
8 years 1 month ago #151294 by nestor
Hide Empty Row was created by nestor
I am generating my table with the "ExtraFields" and wondering how could I hide an empty rows.

Below is the code that I am thinking adding in item.php. It shows the table but there are grays
<?php $this->items = array_merge($this->leading, $this->primary, $this->secondary, $this->links); ?>
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>

<table class="table table-striped" width="100%" >
<tbody>
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<tr>
<td valign="top"> <?php echo $this->item->extraFields->NAME->name; ?> </td>
<td valign="top"> <?php echo $this->item->extraFields->NAME->value; ?></td>
</tr>
<?php endif;?>

<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<tr>
<td valign="top"> <?php echo $this->item->extraFields->TEL->name; ?> </td>
<td valign="top"> <?php echo $this->item->extraFields->TEL->value; ?></td>
</tr>
<?php endif;?>

<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<tr>
<td valign="top"> <?php echo $this->item->extraFields->FAX->name; ?> </td>
<td valign="top"> <?php echo $this->item->extraFields->FAX->value; ?></td>
</tr>
<?php endif;?>

<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<tr>
<td valign="top"> <?php echo $this->item->extraFields->EMAIL->name; ?> </td>
<td valign="top"> <?php echo $this->item->extraFields->EMAIL->value; ?></td>
</tr>
<?php endif;?>
</tbody>
</table>

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 1 month ago #151307 by Krikor Boghossian
Replied by Krikor Boghossian on topic Hide Empty Row
You were close Nestor.

You need to check if that extrafield exists and it has a value.
Use this as a starting point and apply it to all your fields.
if( isset( $this->item->extraFields->EXTRAFIELDALIASHERE->value ) && ( $this->item->extraFields->EXTRAFIELDALIASHERE->value ! == '') ) 

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • nestor
  • nestor's Avatar Topic Author
  • Offline
  • New Member
More
8 years 1 month ago #151321 by nestor
Replied by nestor on topic Hide Empty Row
Thanks Krikor.

I tried below but I cant make it work, it gives me white page. Perhaps you can show me a sample (IS and SHOULD BE format, for example:.

IS:
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
<tr>
<td valign="top"> <?php echo $this->item->extraFields->TEL->name; ?> </td>
<td valign="top"> <?php echo $this->item->extraFields->TEL->value; ?></td>
</tr>
<?php endif;?>

SHOULD BE:
<?php if( isset( $this->item->extraFields->TEL->value ) && ( $this->item->extraFields->TEL->value ! == '') ) : ?>
<tr>
<td valign="top"> <?php echo $this->item->extraFields->TEL->name; ?> </td>
<td valign="top"> <?php echo $this->item->extraFields->TEL->value; ?></td>
</tr>
<?php endif;?>

Sorry for asking too much, and thanks again. Let me know please.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 1 month ago #151344 by Krikor Boghossian
Replied by Krikor Boghossian on topic Hide Empty Row
Enable error reporting from your site's global configuration menu to see the exact PHP error.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • nestor
  • nestor's Avatar Topic Author
  • Offline
  • New Member
More
8 years 1 month ago #151354 by nestor
Replied by nestor on topic Hide Empty Row
Enable and found the culprit, just removed a space between ! and == , plus add colon (:) at the end of the code.

It should be:
if( isset( $this->item->extraFields->EXTRAFIELDALIASHERE->value ) && ( $this->item->extraFields->EXTRAFIELDALIASHERE->value !== '') ):

Big thanks Krikor ;-)

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 1 month ago #151363 by Krikor Boghossian
Replied by Krikor Boghossian on topic Hide Empty Row
You 're welcome Nestor :)

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum