- Posts: 190
COMMUNITY FORUM
Hide extra field if value is empty
- Nick
-
Topic Author
- Offline
- Elite Member
The only solution i can think of is to create some sort of php function and a field inside the extra fields table in mysql which caries the styling. Then have php parse out the style and apply it to the actual field when it's being rendered. But that's just what i can come up with now. You can also do it with javascript but not sure how.
Please Log in or Create an account to join the conversation.
- Peter Monti
-
- Offline
- New Member
- Posts: 7
adding this line <?php $custom = $this->item->extra_fields; ?> and then addressing extra fields for the item like <?php echo $custom[1]->value;? as long as the order of the fields is static.
Please Log in or Create an account to join the conversation.
- Nick
-
Topic Author
- Offline
- Elite Member
- Posts: 190
Please Log in or Create an account to join the conversation.
- Peter Monti
-
- Offline
- New Member
- Posts: 7
wow thanks alot....ive been going nutz here
Please Log in or Create an account to join the conversation.
- Nick
-
Topic Author
- Offline
- Elite Member
- Posts: 190
pastebin.com/Fr8L6Vza
rename your old item.php to something else.
paste the code from pastebin in a new item.php
tell me the results pls :)
Please Log in or Create an account to join the conversation.
- Peter Monti
-
- Offline
- New Member
- Posts: 7
Please Log in or Create an account to join the conversation.
- Nick
-
Topic Author
- Offline
- Elite Member
- Posts: 190
tag it's own style.
Please Log in or Create an account to join the conversation.
- Peter Monti
-
- Offline
- New Member
- Posts: 7
Please Log in or Create an account to join the conversation.
- Nick
-
Topic Author
- Offline
- Elite Member
- Posts: 190
Please Log in or Create an account to join the conversation.
- Wouter
-
- Offline
- New Member
- Posts: 12
But is there a way to show only the first 4 extra fields in category view? And then show all extra fields in the item view?
I have about 15 extra fields.
Thanks in advance!
Please Log in or Create an account to join the conversation.
- Nick
-
Topic Author
- Offline
- Elite Member
- Posts: 190
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.
- Wouter
-
- Offline
- New Member
- Posts: 12
Please Log in or Create an account to join the conversation.
- Wouter
-
- Offline
- New Member
- Posts: 12
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.
- Bjern Potgieter
-
- Offline
- New Member
It's literally 2 lines of code you can add.
Please Log in or Create an account to join the conversation.