make a relation field that has no value, invisible

More
4 years 8 months ago #78423 by philippeg


Hi
I have a relation field (list of relation items): I would like nothing to be visible in case of empty value; how can i do that?
Thanks

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

More
4 years 8 months ago #78424 by ggppdk
Hello

add the field to the 'renderonly' position of your
category or item layout

then output it manually in your item.php or in you category items.php
you check if ->display is empty
Code:
<?php $field = $item->fields['somefieldname']; if ($field->display) { echo '<label> ' . $field->label . '</label>'; echo '<div> ' . $field->display . '</div>'; } ?>


-- 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
4 years 8 months ago #78428 by philippeg
Thanks, the code is working well but only if don't put the field on renderonly area because if i do that i no longer see the field in any condition .. something i did not understood ?

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

More
4 years 8 months ago #78433 by micker
renderonly doesn't display field only use for coding

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
4 years 8 months ago #78434 by philippeg
I know in this case why ggpk ask me to put the field in this area ?

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

More
4 years 8 months ago - 4 years 8 months ago #78436 by ggppdk
Hello

you have to do both of the steps

1. add field to 'renderonly' position (this creates the field but does not display it)
2. then you use the custom PHP code to display the field that was created at step 1

did you do both steps ?

until you also do step 2 , nothing will be shown !


-- 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...
Last edit: 4 years 8 months ago by ggppdk.

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.422 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