Conditional display in item view

More
4 years 2 months ago #79448 by nexteo
Hello

I want to set up in the item view, an accordion with several variables (position1, position2, position, 3 etc ...)
See the code below

How to set a condition so that the accordion
- not displayed if the 3 corresponding positions are empty?
- or is displayed if one of the 3 positions is not empty?
I tried several tests like <? if (! empty ($ idposition1)) || (! empty ($ idposition2)) || (! empty ($ idposition3)) {...}?>
but it doesn't work and unfortunately I don't know how to code in php

Thank you in advance for your help.

****************************************
[zt_accordions type="accordion"]
[zt_accordion title="Main title" active="no"]
<?php foreach ($this->item->positions as $field) : ?>
<?php echo $field->display; ?>
<?php endforeach; ?>
<?php foreach ($this->item->positions as $field) : ?>
<?php echo $field->display; ?>
<?php endforeach; ?>
<?php foreach ($this->item->positions as $field) : ?>
<?php echo $field->display; ?>
<?php endforeach; ?>
[/zt_accordion]
[/zt_accordions]

******************************

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

More
4 years 2 months ago - 4 years 2 months ago #79457 by iamrobert
Hi nexteo,

You probably need more info of what you're trying to achieve.

But you can use raw values to make an accordion if you're aiming for a accordion FAQ:

www.dr-eye.com.tw/about/faq

I use field groups with 2 fields:




Code:
<div class="row"> <div class="small-12"> <?php //title $question_id = 156; // brief $answer_id = 157; // image // Use in ITEM view / Category (multi-items) view $titlevals = $item->fieldvalues[$question_id]; $maintextvals = $item->fieldvalues[$answer_id]; // Title if (!empty($titlevals)) foreach ($titlevals as $t) { if ( @unserialize($t)!== false || $t=== 'b:0;' ) $t = unserialize($t); // var_dump($v); } // Main Text/Complete if (!empty($maintextvals)) foreach ($maintextvals as $maintext) { if ( @unserialize($maintext)!== false || $maintext=== 'b:0;' ) $maintext = unserialize($maintext); // var_dump($maintext); } $count =0; if (!empty($titlevals) or !empty($maintextvals)) foreach ($titlevals as $t) { $title_value[$count] = $t; $count++; } $count4 =0; if (!empty($maintextvals)) foreach ($maintextvals as $maintext) { $maintext_value[$count4] = $maintext; $count4++; } echo '<ul class="accordion" data-accordion>'; //EACH ACCORDION ITEM for($i=0; $i<$count; $i++){ $t = $i; if ($t == 0) { $t = ' is-active'; }; echo '<li class="accordion-item'.$t.'" data-accordion-item>'; echo '<a href="#faq-'.$i.'" class="accordion-title">'.$title_value[$i].'</a>'; echo '<div class="accordion-content" data-tab-content>'; echo $maintext_value[$i]; echo '</div></li>'; } echo '</ul>'; ?> </div> </div>
Last edit: 4 years 2 months ago by iamrobert.

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

More
4 years 2 months ago #79461 by nexteo
Hello,
I've never paid attention to this notion of a group, but I think it fits my needs perfectly.
Indeed, I just have to test the position of the group, regardless of the number of values belonging to this group

Thank you very much for this information

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

More
4 years 2 months ago #79462 by micker
you can do it more simple (but less powerfull)
1 accordeon plugin by regular
2 use groupe field with prefix and set plugin execution inside like

title" ...


3 closed open

=> you can render each filed inside tab

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 1 month ago #79473 by nexteo
Thanks Micker

these 2 proposals perfectly answer my problem
This component is awesome, there is always a soution

Thank you all for your help

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

More
4 years 1 month ago #79474 by micker
with pleasure

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.

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