Indien er een resultaat wordt gevonden (specifieke rij uit repeater) wordt deze uitgelicht.
<?php
/*
* Template name: Certificaten
*/
global $post;
// retrieve our search query if applicable
$query = isset( $_REQUEST['swpquery'] ) ? sanitize_text_field( $_REQUEST['swpquery'] ) : '';
// retrieve our pagination if applicable
$swppg = isset( $_REQUEST['swppg'] ) ? absint( $_REQUEST['swppg'] ) : 1;
if ( class_exists( 'SWP_Query' ) ) {
$engine = 'certificaten';
$swp_query = new SWP_Query(
// see all args at https://searchwp.com/docs/swp_query/
array(
's' => $query,
'engine' => $engine,
'page' => $swppg,
)
);
// set up pagination
$pagination = paginate_links( array(
'format' => '?swppg=%#%',
'current' => $swppg,
'total' => $swp_query->max_num_pages,
) );
}
/*
* Template name: Certificaten
*/
get_header();
include('layout.php'); ?>
<div class="container-fluid crtfctn" style="padding: 0px 0px 45px 0px;">
<div class="container">
<div class="row">
<div class="col-12">
<?php if(is_user_logged_in()) { ?>
<div class="search-box">
<form role="search" method="get" class="search-form" id="searchform-certificates" action="<?php echo esc_html( get_permalink() ); ?>">
<input type="search" id="s-certificates" class="search-field" placeholder="Search..." value="" name="swpquery" title="Search for:">
<input type="submit" id="searchsubmit-certificates" value="Zoek" placeholder="" />
</form>
</div>
</div>
</div>
<div class="row mrgnbtm">
<div class="col-12">
<?php if ( ! empty( $query ) && isset( $swp_query ) && ! empty( $swp_query->posts ) ) {
foreach ( $swp_query->posts as $post ) {
setup_postdata( $post );
$product = wc_get_product( get_the_ID() );
$sku = $product->get_sku();
if( have_rows('certificaten') ): ?>
<table id="certificates-list" cellspacing="1">
<thead>
<tr>
<th>Chargenummer</th>
<th>Bestand</th>
</tr>
</thead>
<tbody>
<?php
while( have_rows('certificaten') ) : the_row();
$chargenummer = get_sub_field('chargenummer');
if($sku == $query){
echo '<tr class="certificate">';
echo '<td>';
echo $chargenummer;
//echo ' --> klant';
echo '</td>';
echo '<td><a href="';
the_sub_field('url');
echo '" target="_BLANK">Download';
echo '</a></td>';
echo '</tr>';
} else {
if($chargenummer != $query){
continue;
}
echo '<tr class="certificate">';
echo '<td>';
echo $chargenummer;
//echo ' --> klant';
echo '</td>';
echo '<td><a href="';
the_sub_field('url');
echo '" target="_BLANK">Download';
echo '</a></td>';
echo '</tr>';
}
endwhile;
?>
</tbody>
</table>
<?php endif;
}
wp_reset_postdata();
// pagination
if ( $swp_query->max_num_pages > 1 ) { ?>
<div class="navigation pagination" role="navigation">
<div class="nav-links">
<?php echo wp_kses_post( $pagination ); ?>
</div>
</div>
<?php }
} else {
?><p>Geen certificaten gevonden.</p><?php
} ?>
<?php } else {
?><p>Log in om de certificaten te downloaden.</p><?php
} ?>
</div>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
#acf #repeater #searchwp