Keyword

Hide extra field if value is empty

  • Nick
  • Nick's Avatar Topic Author
  • Offline
  • Elite Member
More
13 years 7 months ago #71764 by Nick
Replied by Nick on topic Hide extra field if value is empty
yes. go to my pastebin post here : pastebin.com/Fr8L6Vza

 

and copy from line 254 to 272 and replace your original extra fields section with that one. then remove lines 265 to 268. That's a very quick fix to your problem. I am not on my computer right now so i can't write out a prettier code. this should fix the problem. You have to put the code in item_list.php i think.

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

More
13 years 7 months ago #71765 by Wouter
Replied by Wouter on topic Hide extra field if value is empty
I've implemented this fix, but nothing happens (all my extra fields are now gone!) I've put this hack in the category_item.php.

 

 

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

More
13 years 7 months ago #71766 by Wouter
Replied by Wouter on topic Hide extra field if value is empty
I've found it!

 

I've changed the code in category_item.php to:

 

<?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?>         <!-- Item extra fields -->        <div class="itemExtraFields">            <h3><?php echo JText::_('Additional Info'); ?></h3>            <ul>                <?php $exfields = $this->item->extra_fields; ?> <!--This part puts the extra fields in a variable-->                <li>                    <span class="itemExtraFieldsLabel"><?php if($exfields[1]->value) echo $exfields[1]->name;?></span>                    <span class="itemExtraFieldsValue"><?php if($exfields[1]->value) echo $exfields[1]->value;?></span>                </li>                <li>                    <span class="itemExtraFieldsLabel"><?php if($exfields[2]->value) echo $exfields[2]->name;?></span>                    <span class="itemExtraFieldsValue"><?php if($exfields[2]->value) echo $exfields[2]->value;?></span>                </li>                            <li>                    <span class="itemExtraFieldsLabel"><?php if($exfields[3]->value) echo $exfields[3]->name;?></span>                    <span class="itemExtraFieldsValue"><?php if($exfields[3]->value) echo $exfields[3]->value;?></span>                </li>                <li>                    <span class="itemExtraFieldsLabel"><?php if($exfields[4]->value) echo $exfields[4]->name;?></span>                    <span class="itemExtraFieldsValue"><?php if($exfields[4]->value) echo $exfields[4]->value;?></span>                </li>            </ul>            <div class="clr"></div>        </div>        <?php endif; ?>

 

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

More
13 years 4 months ago #71767 by Bjern Potgieter
Replied by Bjern Potgieter on topic Hide extra field if value is empty
I know this is old but for anyone searching these forums, you can find a tutorial on hiding extra empty fields at: toxzen.co.za/webdevoloper/item/34-hide-empty-k2-extra-fields-in-joomla

It's literally 2 lines of code you can add.

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


Powered by Kunena Forum