Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // template for search form
- if (isset($_GET['soort'])) :
- // get current category
- $currentCategory = get_term_by('slug', $_GET['soort'], 'soort');
- if ($currentCategory) :
- ?>
- <div class="container container--narrow">
- <?php
- $soort_image = get_field('soort_image', 'soort_'.$currentCategory->term_id);
- // print_r($soort_image);
- if ( $soort_image !== false ) {
- $cat_img_array = wp_get_attachment_image_src( $soort_image, 'kennisbank', false );
- $cat_img = $cat_img_array[0];
- }
- ?>
- <section class="filter-info <?php if ( $cat_img) { echo 'met-image'; } ?>">
- <?php if ( $cat_img) { ?>
- <img class="filter-info__image" src="<?php echo $cat_img; ?>" alt="" />
- <?php } ?>
- <div class="filter-info__info">
- <h1 class="filter-info__title"><?php echo $currentCategory->name; ?></h1>
- <p class="filter-info__description"><?php echo term_description($currentCategory->term_id, 'soort'); ?></p>
- </div>
- </section>
- </div>
- <?php
- endif;
- endif;
- // get children of current category
- $term_children = get_term_children( $currentCategory->term_id, 'soort' );
- // if there are no children
- if ( !$term_children ) {
- if ( isset( $_REQUEST['swpquery'] )) {
- $query = esc_html($_REQUEST['swpquery']);
- }
- else {
- $query = '';
- }
- if ( isset( $_REQUEST['soort'] )) {
- $soort = esc_html($_REQUEST['soort']);
- }
- else {
- $soort = '';
- }
- $split_soort = explode(",", $soort);
- if ( isset( $_REQUEST['thema'] )) {
- $thema = esc_html($_REQUEST['thema']);
- }
- else {
- $thema = '';
- }
- $split_thema = explode(",", $thema);
- if ( isset( $_REQUEST['country'] )) {
- $country = esc_html($_REQUEST['country']);
- }
- else {
- $country = '';
- }
- $split_country = explode(",", $country);
- $placeholder_zoeken = __("Search for title, document type or another search term", "kncv");
- $search = __("Search", "kncv");
- $advanced_search = __("Advanced search", "kncv");
- ?>
- <form role="search" method="get" class="search" action="<?php echo get_permalink(icl_object_id(32, 'page', true)); ?>">
- <div class="container container--narrow">
- <fieldset class="search__terms">
- <label class="search__label" for="search-knowledgebase"><?php echo $search; ?></label>
- <input class="search__input" type="search" id="search-knowledgebase" name="swpquery" value="<?php echo $query; ?>" placeholder="<?php echo $placeholder_zoeken; ?>">
- <button class="search__submit" type="submit"><?php echo $search; ?></button>
- </fieldset>
- <?php
- // advanced search
- $countries = get_posts( array( 'post_type' => 'land', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => '-1', 'suppress_filters' => 0 ));
- $soorten = get_terms( 'soort', array( 'hide_empty' => true, 'suppress_filters' => 1 ) );
- $themas = get_terms( 'thema', array( 'hide_empty' => true, 'suppress_filters' => 0 ) );
- ?>
- <fieldset class="search__advanced">
- <legend class="search__toggle-advanced"><?php echo $advanced_search; ?></legend>
- <?php if ( !empty($countries) ) { ?>
- <input type="hidden" name="country">
- <ul class="search__filters">
- <?php foreach ( $countries as $country ) { ?>
- <li class="search__filter">
- <label class="checkbox-label search__filter-label">
- <input type="checkbox" class="checkbox search__filter-checkbox" data-search-filter="country" name="<?php echo $country->post_name; ?>" value="<?php echo $country->post_name; ?>" <?php if ( in_array( $country->post_name, $split_country) ) { echo " checked"; } ?>> <?php echo $country->post_title; ?>
- </label>
- </li>
- <?php } ?>
- </ul>
- <?php } if ( !empty($soorten) ) { ?>
- <input type="hidden" name="soort" value="<?php echo $soort; ?>">
- <ul class="search__filters">
- <?php foreach ( $soorten as $soort ) { ?>
- <li class="search__filter">
- <label class="checkbox-label search__filter-label">
- <input type="checkbox" class="checkbox search__filter-checkbox" data-search-filter="soort" name="taxonomy" value="<?php echo $soort->slug; ?>" <?php if ( in_array( $soort->slug, $split_soort) ) { echo " checked"; } ?>> <?php echo kncv_translated_term_name($soort); ?>
- </label>
- </li>
- <?php } ?>
- </ul>
- <?php } ?>
- <?php if ( !empty($themas) ) { ?>
- <input type="hidden" name="thema" value="<?php echo $thema; ?>">
- <ul class="search__filters">
- <?php foreach ( $themas as $thema ) { ?>
- <li class="search__filter">
- <label class="checkbox-label search__filter-label">
- <input type="checkbox" class="checkbox search__filter-checkbox" data-search-filter="thema" name="taxonomy" value="<?php echo $thema->slug; ?>" <?php if ( in_array( $thema->slug, $split_thema) ) { echo " checked"; } ?>> <?php echo kncv_translated_term_name($thema); ?>
- </label>
- </li>
- <?php
- }
- echo '</ul>';
- }
- ?>
- </fieldset>
- </div>
- </form>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement