How do I show or hide a field depending on the value in another field?

More
7 years 5 months ago - 7 years 5 months ago #67863 by ggppdk
Hello

Edit files:

item.php OR
item_html5.php OR
category_items.php OR
category_items_html5.php OR


And add in them code like:
Code:
if ( isset($item->fieldvalues[45]) && count($item->fieldvalues[45]) ) { if ($item->fieldvalues[45][0] == 'somevalue') { echo FlexicontentFields::getFieldDisplay($item, 'some_field_name'); } }

45 is the id of the field that controls showing the HTML of the field with name 'some_field_name'


-- 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: 7 years 5 months ago by ggppdk.

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

More
7 years 5 months ago #67867 by Akir

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

More
7 years 5 months ago #67874 by ggppdk
Also

If field 45 has multiple values and you would like to check them all,
then use:
Code:
if ( isset($item->fieldvalues[45]) && count($item->fieldvalues[45]) ) { if (in_array('somevalue', $item->fieldvalues[45])) { echo FlexicontentFields::getFieldDisplay($item, 'some_field_name'); } }

Out of the above 2 answers i have made a new FAQ article
www.flexicontent.org/documentation/tutor...f-another-field.html


-- 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.723 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