Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sarathlal-old/534a14cd719f7f9627c3f972c96fa05c to your computer and use it in GitHub Desktop.
Save sarathlal-old/534a14cd719f7f9627c3f972c96fa05c to your computer and use it in GitHub Desktop.
<?php
/*
Template Name: archive
*/
get_header();
wp_enqueue_script('magnific');
add_action('wp_footer', 'san_scripts', 21);
function san_scripts() {
?>
<script>
$('#inline-popups').magnificPopup({
delegate: 'a',
removalDelay: 500, //delay removal by X to allow out-animation
callbacks: {
beforeOpen: function() {
this.st.mainClass = this.st.el.attr('data-effect');
}
},
midClick: true
});
function updateQueryStringParameter(uri, key, value) {
var re = new RegExp("([?|&])" + key + "=.*?(&|$)", "i");
console.log(re);
separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
return uri.replace(re, '$1' + key + "=" + value + '$2');
//alert("key exist");
}
else {
return uri + separator + key + "=" + value;
// alert("No key");
}
}
jQuery('.chkbox').change(function(){
var item = [];
var arr = [];
jQuery('#search-portfolio input').each(function(){
var m = 0;
//your code here
//alert(jQuery(this).val());
if(this.checked) {
//alert(jQuery(this).val());
var key = jQuery(this).attr("name");
var val = jQuery(this).val();
item = [key, val];
console.log(item);
arr.push(item);
m++;
}
});
console.log(arr);
// if(this.checked) {
// window.location = jQuery(this).val();
//}
});
jQuery("#search-3 #searchform").submit(function () {
if (jQuery('#search-3 #searchform #s').val() != "")
{
return true;
}
jQuery('#search-3 #searchform #s').focus();
return false;
});
</script>
<?php }
?>
<div class="portfolio-page">
<div class="container clearfix">
<div class="left-sec">
<h2>Filter by</h2>
<?php
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//echo $url; // Outputs: Full URL
if (strpos($url,'?') !== false) {
$action = $url;
} else {
$action = get_home_url() . "/portfolio/?";
}
?>
<form id="search-portfolio" action="<?php echo $action; ?>">
<?php
$taxonomies = array('portfolio-initiative','portfolio-country','portfolio-legacy-investments');
foreach($taxonomies as $taxonomy) {
$terms = get_terms( array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
) );
if(!empty($terms)) {
$taxonomy_details = get_taxonomy( $taxonomy );
echo "<ul>";
echo "<li><h3>".$taxonomy_details->label."</h3></li>";
foreach ($terms as $term) { ?>
<?php //var_dump( $term); ?>
<li>
<input type="checkbox" id="chkbox<?php echo $term->term_id; ?>" class="chkbox" name="<?php echo $taxonomy; ?>" value="<?php echo $term->slug; ?>" />
<label for="chkbox<?php echo $term->term_id; ?>"><span class="list-name"><?php echo $term->name; ?></span></label>
</li>
<?php
}
echo "</ul>";
}
}
?>
</form>
<ul>
<li><h3>Initiative</h3></li>
<li>
<input type="checkbox" id="chkbox1" class="chkbox" name="" value="" />
<label for="chkbox1"><span class="list-name">All</span></label>
</li>
<li>
<input type="checkbox" id="chkbox2" class="chkbox" name="" value="" />
<label for="chkbox2"><span class="list-name">Direct Investments</span></label>
</li>
<li>
<input type="checkbox" id="chkbox3" class="chkbox" name="" value="" />
<label for="chkbox3"><span class="list-name">Fund of Funds</span></label>
</li>
<li>
<input type="checkbox" id="chkbox4" class="chkbox" name="" value="" />
<label for="chkbox4"><span class="list-name">coLABS</span></label>
</li>
<li>
<input type="checkbox" id="chkbox5" class="chkbox" name="" value="" />
<label for="chkbox5"><span class="list-name">edLABS</span></label>
</li>
<li>
<input type="checkbox" id="chkbox6" class="chkbox" name="" value="" />
<label for="chkbox6"><span class="list-name">Ecosystem Investments</span></label>
</li>
</ul>
<ul>
<li><h3>Country</h3></li>
<li>
<input type="checkbox" id="chkbox7" class="chkbox" name="" value="" />
<label for="chkbox7"><span class="list-name">All</span></label>
</li>
<li>
<input type="checkbox" id="chkbox8" class="chkbox" name="" value="" />
<label for="chkbox8"><span class="list-name">US</span></label>
</li>
<li>
<input type="checkbox" id="chkbox9" class="chkbox" name="" value="" />
<label for="chkbox9"><span class="list-name">INDIA</span></label>
</li>
<li>
<input type="checkbox" id="chkbox10" class="chkbox" name="" value="" />
<label for="chkbox10"><span class="list-name">LATIN AMERICA</span></label>
</li>
<li>
<input type="checkbox" id="chkbox11" class="chkbox" name="" value="" />
<label for="chkbox11"><span class="list-name">AFRICA</span></label>
</li>
<li>
<input type="checkbox" id="chkbox12" class="chkbox" name="" value="" />
<label for="chkbox12"><span class="list-name">OTHERS</span></label>
</li>
</ul>
<ul>
<li><h3>LEGACY INVESTMENTS</h3></li>
<li>
<input type="checkbox" id="chkbox13" class="chkbox" name="" value="" />
<label for="chkbox13"><span class="list-name">All</span></label>
</li>
<li>
<input type="checkbox" id="chkbox14" class="chkbox" name="" value="" />
<label for="chkbox14"><span class="list-name">Direct Investments</span></label>
</li>
<li>
<input type="checkbox" id="chkbox15" class="chkbox" name="" value="" />
<label for="chkbox15"><span class="list-name">Fund of Funds</span></label>
</li>
</ul>
</div>
<div class="right-sec">
<div class="tag1">
<ul>
<li><span class="fltr">INDIA</span><span class="close">X</span></li>
<li><span class="fltr">INDIA</span><span class="close">X</span></li>
</ul>
</div>
<div class="tag2">
<?php if (have_posts()) : ?>
<ul id="inline-popups">
<?php while (have_posts()) : the_post(); ?>
<li>
<a href="#popup-<?php echo $post->ID; ?>" data-effect="mfp-zoom-in">
<div class="content">
<?php $logo = get_field('logo');
if(empty($logo)){
$logo = get_template_directory_uri() ."/theme-assets/portfolio-logo.jpg";
}
?>
<div class="logo">
<img src="<?php echo $logo; ?>" alt="<?php the_title(); ?>" />
</div>
<?php $country = get_the_terms( $post->ID, 'portfolio-country' );
if ( !empty( $country ) ){
// get the first term
$term = array_shift( $country );
//echo $term->name;
$term_id = $term->term_id;
//var_dump($term);
$flag = get_field('flag', $term);
}
if(!empty($flag)) {
?>
<div class="flag">
<img src="<?php echo $flag; ?>" alt="<?php echo $term->name; ?>" />
</div>
<?php } ?>
<h3><?php the_title(); ?></h3>
<?php $short_content = limit_words (get_the_excerpt(), 10);
echo wpautop($short_content);
?>
</div>
</a>
<!--pop up content-->
<div id="popup-<?php echo $post->ID; ?>" class="white-popup mfp-with-anim mfp-hide">
<div class="content">
<div class="logo">
<img src="<?php echo $logo; ?>" alt="<?php the_title(); ?>" />
</div>
<?php if(!empty($flag)) { ?>
<div class="flag">
<img src="<?php echo $flag; ?>" alt="<?php echo $term->name; ?>" />
</div>
<?php } ?>
<?php $url = get_field('url'); ?>
<h3><?php the_title(); ?> <?php if(!empty($url)) { ?><span class="portfolio-url"><a href="<?php echo $url; ?>" target="_blank" alt="<?php the_title(); ?>"><?php echo $url; ?></a></span><?php } ?></h3>
<?php $sub_title = get_field('sub_title'); ?>
<?php if(!empty($sub_title)) { ?><h4 class="portfolio-subtitle"><?php echo $sub_title; ?></h4><?php } ?>
<?php the_content(); ?>
</div>
</div>
<!--pop up content end-->
</li>
<?php endwhile; ?>
</ul>
<div class="pagination clearfix" style="clear: both;">
<?php $big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'prev_text' => __('Previous'),
'next_text' => __('Next'),
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) ); ?>
</div>
<?php
else :
echo '<div class="outer-ar"><div class="blg-item">';
echo '<h2> No posts found ! </h2>';
echo '</div></div>';
endif;
?>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment