I'm trying to present a clean easy to use client back end field submission in the WP Admin dashboard that can sort repeater field data into appropriate tabbed content. here is the setup.
Field setup
Backend
Frontend
The code I tried;
<div class="tab-pane fade" id="tab-1-3">
<ul class="nav nav-pills" role="tablist">
<li role="presentation" class="active">English</li>
<li role="presentation">Spanish</li>
</ul>
<div class="tab-content lang-tab-content">
<div role="tabpanel" class="tab-pane active" id="english">
<?php
$count=0;
if( have_rows('article') ):
while ( have_rows('article') ) : the_row();
?>
<?php if (the_sub_field('language') == 'English') { ?>
<strong>Published Date:</strong> <?php the_sub_field('publised_date');?>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading<?php echo $count ?>">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo $count ?>" aria-expanded="false" aria-controls="collapse<?php echo $count ?>">
<?php the_sub_field('article_title');?>
</a>
</h4>
</div>
<div id="collapse<?php echo $count ?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading<?php echo $count ?>">
<div class="panel-body">
<?php the_sub_field('article_body');?>
</div>
</div>
</div>
</div>
<?php } ?>
<?php
$count++;
endwhile;
else :
endif;
?>
</div>
<div role="tabpanel" class="tab-pane" id="spanish">Spanish</div>
</div>
</div><!-- tab-pane -->
please show the loop code. Without any information about your code this is pretty hard to answer.
I would simply loop through all the repeater rows and set a class to hide the elements based on the prefered language. Then toggle the class with javascript on button click.
UPDATE
<?php
$count=0; $english =''; $spanish ='';
if( have_rows('article') ):
while ( have_rows('article') ) : the_row();
$count++;
if (the_sub_field('language') == 'English'){
$english .= '<strong>Published Date: '.get_sub_field('publised_date').'</strong>';
$english .= '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"><div class="panel panel-default">';
/** PANEL HEADING **/
$english .= '<div class="panel-heading" role="tab" id="heading'.$count.'">';
$english .= '<h4 class="panel-title">';
$english .= '<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse'.$count.'" aria-expanded="false" aria-controls="collapse'.$count.'">';
$english .= get_sub_field('article_title');
$english .= '</a></h4></div>';
/** END PANEL HEADING **/
/** COLLAPSE START **/
$english .= '<div id="collapse'.$count.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading'.$count.'"><div class="panel-body">'.get_sub_field('article_body').'</div></div>';
/** COLLAPS END **/
$english .= '</div></div>';
}
else{
$spanish .= '<strong>Published Date: '.get_sub_field('publised_date').'</strong>';
$spanish .= '<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"><div class="panel panel-default">';
/** PANEL HEADING **/
$spanish .= '<div class="panel-heading" role="tab" id="heading'.$count.'">';
$spanish .= '<h4 class="panel-title">';
$spanish .= '<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse'.$count.'" aria-expanded="false" aria-controls="collapse'.$count.'">';
$spanish .= get_sub_field('article_title');
$spanish .= '</a></h4></div>';
/** END PANEL HEADING **/
/** COLLAPSE START **/
$spanish .= '<div id="collapse'.$count.'" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading'.$count.'"><div class="panel-body">'.get_sub_field('article_body').'</div></div>';
/** COLLAPS END **/
$spanish .= '</div></div>';
}
endwhile;
endif;
?>
<div class="tab-content lang-tab-content">
<div role="tabpanel" class="tab-pane active" id="english">
<?php echo $english; ?>
</div>
<div role="tabpanel" class="tab-pane" id="spanish">
<?php echo $spanish; ?>
</div>
</div>
Solved.
<ul class="nav nav-pills" role="tablist">
<li role="presentation" class="active">English</li>
<li role="presentation">spanish</li>
</ul>
</div>
<div class="tab-content lang-tab-content">
<div role="tabpanel" class="tab-pane active" id="english">
<?php $ons=0; if(get_field('own_news')): ?>
<?php while(has_sub_field('own_news')): ?>
<?php if( get_sub_field('language') == 'English' ): ?>
<strong>Published Date:</strong> <?php the_sub_field('publised_date');?>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading<?php echo $ons ?>">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo $ons ?>" aria-expanded="false" aria-controls="collapse<?php echo $ons ?>"><?php the_sub_field('article_title');?></a>
</h4>
</div>
<div id="collapse<?php echo $ons ?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading<?php echo $ons ?>">
<div class="panel-body">
<?php the_sub_field('article_body');?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php $ons++; endwhile; ?>
<?php endif; ?>
</div>
<div role="tabpanel" class="tab-pane" id="spanish">
<?php $ons=200; if(get_field('own_news')): ?>
<?php while(has_sub_field('own_news')): ?>
<?php if( get_sub_field('language') == 'Spanish' ): ?>
<strong>Published Date:</strong> <?php the_sub_field('publised_date');?>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading<?php echo $ons ?>">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse<?php echo $ons ?>" aria-expanded="false" aria-controls="collapse<?php echo $ons ?>"><?php the_sub_field('article_title');?></a>
</h4>
</div>
<div id="collapse<?php echo $ons ?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading<?php echo $ons ?>">
<div class="panel-body">
<?php the_sub_field('article_body');?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php $ons++; endwhile; ?>
<?php endif; ?>
</div>
</div>
Related
I am using Bootstrap Accordion with ACF and have a repeater in a repeater section. I get all the data and it is displayed as it should be but when I click on the title to open the body the class changes to "collapse show" and the accordion opens for a fraction of a second only to close again immediately. Does any one have any ideas? Here's the code:
<div id="accordion">
<div class="card">
<?php
if( have_rows('instructions_android')):
$i = 1;
while ( have_rows('instructions_android')) : the_row();
?>
<div class="card-header" id="heading<?php echo $i; ?>">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapse<?php echo $i; ?>" aria-expanded="false" aria-controls="collapse<?php echo $i; ?>">
<span class="instr-title"><?php echo get_sub_field('etape_installation_no'); ?> : </span><span class="instr-title"><?php echo get_sub_field('titre_du_step'); ?></span>
</button>
</h5>
</div>
<div id="collapse<?php echo $i; ?>" class="collapse" aria-labelledby="heading<?php echo $i; ?>" data-parent="#accordion">
<?php
$i++;?>
<div class="card-body">
<ul>
<?php
$j = 1;
if( have_rows('descr_step')):
while ( have_rows('descr_step')) : the_row();
?>
<li><?php echo get_sub_field('description'); ?></li>
<?php
$j++;
endwhile; ?>
</ul>
<?php endif; ?>
</div><!--card body-->
</div>
</div><!--card-->
<?php endwhile;
endif;?>
</div>
I am using Bootstrap tabs to display a grid with employee profiles and photo's in ACF repeater fields and when clicking on the profile a bootstrap modal pops up with the information filled out in a repeater sub field.
Everything is working fine, but when you click on the different profiles, the same profile information is in the modal and not different profile information.
Here is my code
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="team" role="tabpanel" aria-labelledby="team-tab">
<div class="row justify-content-md-between">
<?php
if( have_rows('team_profile_boxes') ):
$i = 1;
// loop through the rows of data
while ( have_rows('team_profile_boxes') ) : the_row(); ?>
<div id="profile-box">
<div class="profile-image-box">
<div class="profile-image" style="background-image: url('<?php echo the_sub_field('profile_image'); ?>');"></div>
<div class="profile-image-hover" style="background-image: url('<?php echo the_sub_field('second_profile_image'); ?>');"></div>
</div>
<div class="profile-details">
<a data-toggle="modal" href="#exampleModal">
<h4>
<span><?php the_sub_field('division_title'); ?></span>
<br>
<?php the_sub_field('profile_name'); ?> <br>
<span><?php the_sub_field('job_title'); ?></span>
</h4>
</a>
</div>
</div>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-body">
<?php the_sub_field('profile_information'); ?>
</div>
</div>
</div>
</div>
<?php $i++;
endwhile;
else :
// no rows found
endif;
?>
</div>
</div>
I've looked through this example but it doesn't seem to apply:
ACF Repeater + Modal
you have not print $i , try this code ...
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="team" role="tabpanel" aria-labelledby="team-tab">
<div class="row justify-content-md-between">
<?php
if( have_rows('team_profile_boxes') ):
$i = 1;
// loop through the rows of data
while ( have_rows('team_profile_boxes') ) : the_row(); ?>
<div id="profile-box-<?php echo $i; ?>">
<?php //your code ?>
</div>
<div class="modal fade" id="profile-box-<?php echo $i; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<?php //your code ?>
</div>
<?php $i++;
endwhile;
else :
// no rows found
endif; ?>
</div>
</div>
</div>
I managed to solve it using the philosophy above but using the following code:
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="team" role="tabpanel" aria-labelledby="team-tab">
<div class="row justify-content-md-between">
<?php
if( have_rows('team_profile_boxes') ):
$i = 1;
// loop through the rows of data
while ( have_rows('team_profile_boxes') ) : the_row(); ?>
<div id="profile-box">
<div class="profile-image-box">
<div class="profile-image" style="background-image: url('<?php echo the_sub_field('profile_image'); ?>');"></div>
<div class="profile-image-hover" style="background-image: url('<?php echo the_sub_field('second_profile_image'); ?>');"></div>
</div>
<div class="profile-details">
<a data-toggle="modal" href="<?php echo '#exampleModal' . $i ?>">
<h4>
<span><?php the_sub_field('division_title'); ?></span>
<br>
<?php the_sub_field('profile_name'); ?> <br>
<span><?php the_sub_field('job_title'); ?></span>
</h4>
</a>
</div>
</div>
<div class="modal fade" id="<?php echo 'exampleModal' . $i ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-body">
<?php the_sub_field('profile_information'); ?>
</div>
</div>
</div>
</div>
<?php $i++;
endwhile;
else :
// no rows found
endif;
?>
</div>
</div>
you can use an acf build-in function called get_row_index() to set an index to all the rows. it starts from 1 and goes up to end of your rows count.
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="team" role="tabpanel" aria-labelledby="team-tab">
<div class="row justify-content-md-between">
<?php if( have_rows('team_profile_boxes') ):
// loop through the rows of data
while ( have_rows('team_profile_boxes') ) : the_row(); $i = get_row_index();?>
<div id="profile-box">
<div class="profile-image-box">
<div class="profile-image" style="background-image: url('<?php echo the_sub_field('profile_image'); ?>');"></div>
<div class="profile-image-hover" style="background-image: url('<?php echo the_sub_field('second_profile_image'); ?>');"></div>
</div>
<div class="profile-details">
<a data-toggle="modal" href="#exampleModal-<?php echo $i;?>">
<h4>
<span><?php the_sub_field('division_title'); ?></span>
<br>
<?php the_sub_field('profile_name'); ?> <br>
<span><?php the_sub_field('job_title'); ?></span>
</h4>
</a>
</div>
</div>
<div class="modal fade" id="exampleModal-<?php echo $i;?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-body">
<?php the_sub_field('profile_information'); ?>
</div>
</div>
</div>
</div>
<?php endwhile; endif; ?>
</div>
</div>
Just wondering if anyone could help me with my code please?
I've setup an ACF Repeater for the Bootstrap Collapse, which displays, but when I click the titles they don't collapse to show the content.
<?php if( have_rows('accordion') ): ?>
<div class="accordion" id="accordion">
<?php $i = 0; ; while ( have_rows('accordion') ) : the_row(); $i++; $tCount = $i; ?>
<div class="card">
<div class="card-header" id="heading<?php echo $tCount; ?>">
<button class="btn btn-link collapsed" type="button" data-toggle="collapse<?php echo $tCount; ?>" data-target="#collapse<?php echo $tCount; ?>" aria-expanded="false" aria-controls="collapse<?php echo $tCount; ?>"><?php the_sub_field('title'); ?></button>
</div><!--End Card Header-->
</div><!--End Card-->
<div id="collapse<?php echo $tCount; ?>" class="collapse" aria-labelledby="heading<?php echo $tCount; ?>" data-parent="#accordionExample">
<div class="card-body">
Text
</div>
</div>
<?php endwhile; ?>
</div><!--End Accordian-->
<?php else : endif; ?>
Thanks!
I got it working, turned out I was echo'ing some PHP in the wrong area. If anybody needs the code, here it is:
<?php if( have_rows('accordion') ): ?>
<div class="accordion" id="accordion">
<?php $i = 0; ; while ( have_rows('accordion') ) : the_row(); $i++; $tCount = $i; ?>
<?php
$field_accordion = get_sub_field_object('accordion_background_colour');
$value_accordion = $field_accordion['value'];
$label_accordion = $field_accordion['choices'][ $value_accordion ];
?>
<div class="card accordion-<?php echo $value_accordion; ?>-background">
<div class="card-header" id="heading<?php echo $tCount; ?>">
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapse<?php echo $tCount; ?>" aria-expanded="false" aria-controls="collapse<?php echo $tCount; ?>">
<h4><?php the_sub_field('title'); ?> <i class="fa fa-arrow-down" aria-hidden="true"></i></h4>
</button>
</div><!--End Card Header-->
</div><!--End Card-->
<div id="collapse<?php echo $tCount; ?>" class="collapse" aria-labelledby="heading<?php echo $tCount; ?>" data-parent="#accordion">
<div class="card-body">
Text
</div>
</div>
<?php endwhile; ?>
</div><!--End Accordian-->
<?php else : endif; ?>
I'm trying to show the featured image or the post thumbnail in every list items < li >. Here's the code:
<div class="row headline">
<ul class="col-md-12 col-sm-12">
<?php
$sql_submenu_produk_sql = $wpdb->get_results("
SELECT * from $wpdb->posts
WHERE post_parent=52 AND post_type='page' AND post_status='publish' group by ID;
");
?>
<?php foreach ($sql_submenu_produk_sql as $row_submenu_sql) { ?>
<li>
<div class="col-md-2 col-xs-12 bordered" style="min-height: 100px;">
<a href="" data-featherlight="image">
<?php echo get_the_post_thumbnail($post->ID); ?>
</a>
</div>
<div class="col-md-10 col-xs-12">
<h2 style="font-weight: normal;"><?php echo $row_submenu_sql->post_title ?></h2>
<p style="padding-bottom: 15px;"><?php echo $row_submenu_sql->post_content ?></p>
</div>
</li>
<?php } ;?>
</ul>
</div>
but, it's not showing after all while on the other page shows. Please help.
Should you have get_the_post_thumbnail($row_submenu_sql->ID); and not $row_submenu_sql->ID $post->ID is not defined in that loop.
<div class="row headline">
<ul class="col-md-12 col-sm-12">
<?php
$sql_submenu_produk_sql = $wpdb->get_results("
SELECT * from $wpdb->posts
WHERE post_parent=52 AND post_type='page' AND post_status='publish' group by ID;
");
?>
<?php foreach ($sql_submenu_produk_sql as $row_submenu_sql) { ?>
<li>
<div class="col-md-2 col-xs-12 bordered" style="min-height: 100px;">
<a href="" data-featherlight="image">
//UPDATE THIS LINE LIKE BELOW
<?php echo get_the_post_thumbnail($row_submenu_sql->ID); ?>
</a>
</div>
<div class="col-md-10 col-xs-12">
<h2 style="font-weight: normal;"><?php echo $row_submenu_sql->post_title ?></h2>
<p style="padding-bottom: 15px;"><?php echo $row_submenu_sql->post_content ?></p>
</div>
</li>
<?php } ;?>
</ul>
</div>
I am in the process of build a layout and need the footer to appear as the following:
http://i.stack.imgur.com/V56Hd.png
Currently, the footer just sits inside of the background, while I need it inside of the white area then on top of the footer background as shown:
Here is the code I have on the footer:
<footer id="footer">
<div class="container">
<div class="row-fluid">
<div class="column span2">
<h3 class="header"><?php echo $text_information; ?> <i class="icon-caret-down"></i></h3>
<ul class="content">
<?php $i=1; foreach ($informations as $information) { ?>
<li id="inf<?php echo $i;?>"><?php echo $information['title']; ?></li>
<?php $i++; } ?>
</ul>
</div>
<div class="column span2">
<h3 class="header"><?php echo $text_service; ?> <i class="icon-caret-down"></i></h3>
<ul class="content">
<li><?php echo $text_contact; ?></li>
<li><?php echo $text_return; ?></li>
<li><?php echo $text_sitemap; ?></li>
</ul>
</div>
<!--<div class="column span2">
<h3 class="header"><?php echo $text_extra; ?> <i class="icon-caret-down"></i></h3>
<ul class="content">
<li><?php echo $text_manufacturer; ?></li>
<li><?php echo $text_voucher; ?></li>
<li><?php echo $text_affiliate; ?></li>
<li><?php echo $text_special; ?></li>
</ul>
</div>-->
<div class="column span2">
<h3 class="header"><?php echo $text_account; ?> <i class="icon-caret-down"></i></h3>
<ul class="content">
<li><?php echo $text_account; ?></li>
<li><?php echo $text_order; ?></li>
<li class="wishlist-link"><?php echo $text_wishlist; ?></li>
<li><?php echo $text_newsletter; ?></li>
</ul>
</div>
<div class="span4">
<?php if($this->config->get('clearshop_status')== 1) { ?>
<div class="social">
<h3><?php echo $this->language->get('text_keep_in_touch'); ?></h3>
<?php if(($this->config->get('clearshop_facebook_page') != '') && ($this->config->get('clearshop_facebook_icon') == 1)) { ?>
<a href="https://facebook.com/<?php echo $this->config->get('clearshop_facebook_page'); ?>" target="_blank">
<i class="icon-facebook-sign"></i>
</a>
<?php } ?>
<?php if(($this->config->get('clearshop_twitter_username') != '') && ($this->config->get('clearshop_twitter_icon') == 1)) { ?>
<a href="https://twitter.com/#!/<?php echo $this->config->get('clearshop_twitter_username'); ?>" target="_blank">
<i class="icon-twitter"></i>
</a>
<?php } ?>
<?php if($this->config->get('clearshop_youtube_username') != '') { ?>
<a href="https://youtube.com/user/<?php echo $this->config->get('clearshop_youtube_username'); ?>" target="_blank">
<i class="icon-youtube"></i>
</a>
<?php } ?>
<?php if($this->config->get('clearshop_gplus_id') != '') { ?>
<a href="https://plus.google.com/u/0/<?php echo $this->config->get('clearshop_gplus_id'); ?>" target="_blank">
<i class="icon-google-plus"></i>
</a>
<?php } ?>
<?php if($this->config->get('clearshop_pinterest_id') != '') { ?>
<a href="https://pinterest.com/<?php echo $this->config->get('clearshop_pinterest_id'); ?>" target="_blank">
<i class="icon-pinterest"></i>
</a>
<?php } ?>
<?php if($this->config->get('clearshop_instagram_username') != '') { ?>
<a href="https://instagram.com/<?php echo $this->config->get('clearshop_instagram_username'); ?>" target="_blank">
<i class="icon-instagram"></i>
</a>
<?php } ?>
<?php if($this->config->get('clearshop_tumblr_username') != '') { ?>
<a href="http://<?php echo $this->config->get('clearshop_tumblr_username'); ?>.tumblr.com" target="_blank">
<i class="icon-tumblr"></i>
</a>
<?php } ?>
<?php if($this->config->get('clearshop_skype_username') != '') { ?>
<a href="skype:<?php echo $this->config->get('clearshop_skype_username'); ?>?call" target="_blank">
<i class="icon-skype"></i>
</a>
<?php } ?>
<?php if($this->config->get('clearshop_linkedin_username') != '') { ?>
<a href="linkedin:<?php echo $this->config->get('clearshop_linkedin_username'); ?>?call" target="_blank">
<i class="icon-linkedin"></i>
</a>
<?php } ?>
</div>
<?php if($this->config->get('clearshop_footer_info_text') != '') { ?>
<div class="info">
<?php echo html_entity_decode($this->config->get('clearshop_footer_info_text'), ENT_QUOTES, 'UTF-8');?>
</div>
<?php } ?>
<?php } ?>
</div>
</div> <!-- .row-fluid -->
</div> <!-- .container -->
</footer> <!-- #footer -->
Well one thing you could try is z-index go to css file and write down
#footer{z-index:9999;}
and see if that works for you, your question is not clear enough, but this was what i understood.