- Posts: 6
COMMUNITY FORUM
Hide Empty Row
- nestor
-
Topic Author
- Offline
- New Member
Less
More
9 years 2 months 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>
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
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 2 months 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.
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 ! == '') )
Please Log in or Create an account to join the conversation.
- nestor
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 6
9 years 2 months 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.
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
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 2 months 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.
Please Log in or Create an account to join the conversation.
- nestor
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 6
9 years 2 months 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 ;-)
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
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 2 months ago #151363
by Krikor Boghossian
Replied by Krikor Boghossian on topic Hide Empty Row
You 're welcome Nestor :)
Please Log in or Create an account to join the conversation.