Hide Empty Fields at Frontend?

More
6 years 3 months ago - 6 years 3 months ago #74662 by Dave LeDev
How do I hide an empty field at the frontend? I tried using If empty at "Hide in item form" under Item form, but it won't work. I tried toggling to Both and it WILL hide the field in the backend but not the front.
Last edit: 6 years 3 months ago by ggppdk.

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

More
6 years 3 months ago #74668 by micker
hello not sure to understand because its native, if filed is empty its not displayed ... can you explain more ?

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

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

More
6 years 3 months ago #74676 by ggppdk
Hello

it works like this

1. if the field has no value then no HTML display is created
-- unless you have custom layout that will create a "default display" or unless the field has been configured to use the default value of form for viewing too

2. Then the template file:
item.php
or
category_items.php

has field positions, that most of them will skip the field if display is NULL
in only a few template like (category) "blog" there are positions that will show the label even if field's display is empty


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

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

More
6 years 3 months ago #74683 by Dave LeDev
I found the function for the desired result. :)

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

More
6 years 3 months ago #74684 by Dave LeDev
However I did note that this customization is not available for individual fields. Looking at the default code, it only checks if the label is set for display and outputs the value regardless. This is true for the tabbed template. Skimming through the code of other templates, I'm not finding a conditional that checks to see if the value is set or not. What's the conditional command to check if the value is set?

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

More
6 years 3 months ago #74689 by ggppdk
Hello

about fieldgroup field you found the setting

about individual fields, the code that --decides-- to show a field that has no HTML display
must be inside
the template files:

item.php
category_items.php

example
Code:
        <div class="flexi lineinfo subtitle1 group">             <?php foreach ($item->positions['subtitle1'] as $field) : ?>             <div class="flexi element field_<?php echo $field->name; ?>">                 <?php if ($field->label) : ?>                 <span class="flexi label field_<?php echo $field->name; ?>"><?php echo $field->label; ?></span>                 <?php endif; ?>                 <div class="flexi value field_<?php echo $field->name; ?>"><?php echo $field->display; ?></div>             </div>             <?php endforeach; ?>         </div>
After foreach add:
Code:
<?php if (!strlen($field->display)) continue; ?>


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.390 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline