Skip to content

Instantly share code, notes, and snippets.

@mrtwebdesign
Created July 5, 2016 14:58
Show Gist options
  • Save mrtwebdesign/51aba8882bf131284efb5fa2b94ac18c to your computer and use it in GitHub Desktop.
Save mrtwebdesign/51aba8882bf131284efb5fa2b94ac18c to your computer and use it in GitHub Desktop.
<?php
/* Template Name: games dynamic */
global $avia_config;
/*
* get_header is a basic wordpress function, used to retrieve the header.php file in your theme directory.
*/
get_header();
if( get_post_meta(get_the_ID(), 'header', true) != 'no') echo avia_title();
?>
<div class='container_wrap container_wrap_first main_color shop_columns_3 <?php avia_layout_class( 'main' ); ?>'>
<div class='container'>
<div class="row game-header-row">
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(),'featured');
$text_overlay = get_post_meta($post->ID,'_moblab_overlay_text',true);
?>
<div class="visible-xs-block col-xs-12 mobile-game-col-left">
<div class="mobile-image-container" style="background-image:url('<?php echo $image[0]; ?>');">
<div class="text_overlay_mobile"><?php echo $text_overlay; ?></div>
</div>
</div>
<div class="hidden-xs col-sm-8 game-header-col game-col-left" style="background-image:url('<?php echo $image[0]; ?>');">
<div class="text_overlay_desktop"><?php echo $text_overlay; ?></div>
</div>
<div class="col-xs-12 col-sm-4 game-header-col game-col-right">
<div class="side-gamelink-container">
<div class="text-overlay-wrap">
<?php $topic_one_id = get_post_meta($post->ID,'_moblab_topic_one',true);
echo $topic_one_id.' - ';
$term_one = get_term_by('id',$topic_one_id,'product_cat');
//print_r($term_one);
echo $term_one->name;
?>
</div>
</div>
<div class="side-gamelink-container">
<div class="text-overlay-wrap">
<?php $topic_two_id = get_post_meta($post->ID,'_moblab_topic_two',true);
echo $topic_two_id.' - ';
$term_two = get_term_by('id',$topic_two_id,'product_cat');
//print_r($term_two);
echo $term_two->name;
?>
</div>
</div>
<div class="side-gamelink-container side-gamelink-container-last">
<div class="text-overlay-wrap">
<?php $topic_three_id = get_post_meta($post->ID,'_moblab_topic_three',true);
echo $topic_three_id.' - ';
$term_three = get_term_by('id',$topic_three_id,'product_cat');
//print_r($term_three);
echo $term_three->name;
?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<?php
$args = wp_parse_args( $query_args, array(
'type' => 'product',
'post_type' => 'product',
'taxonomy' => 'category',
) );
$product_categories = get_terms( 'product_cat', $args );
$product_categories_hierarchical = array();
sort_terms_hierarchicaly($product_categories, $product_categories_hierarchical);
?>
<pre>
<?php print_r($product_categories_hierarchical[0]); ?>
</pre>
<?php ?>
</div>
</div>
<div class="row row-search-bar">
<div class="col-md-4">temp text
</div>
<div class="col-md-4 filters">
<ul class="nfacet-controls">
<li>
<div class="nfacetwp-facet nfacetwp-type-dropdown">
<select id="filterset" class="nfacetwp-dropdown">
<option value="all">Filter By: Please Select</option>
<option value="featured">Filter By: Featured</option>
<option value="test">TEST</option>
<option value="favorites">Filter By: Favorites</option>
<?php foreach($product_categories_hierarchical as $product_category){
$value = $product_category->slug;
$name = $product_category->name.' ('.$product_category->count.')';
echo '<option value="'.$value.'">'.$name.'</option>';
if ( count($product_category->children) > 0 ){
foreach($product_category->children as $category_child){
$value = $category_child->slug;
$name = $category_child->name.' ('.$category_child->count.')';
echo '<option value="'.$value.'">&nbsp;&nbsp;'.$name.'</option>';
}
}
}
?>
</select>
</div>
</li>
<li class="hidden topics-wrap">
<?php //echo apply_filters( 'the_content', '[facetwp facet="topics"]' ); ?>
</li>
<li class="hidden featured-wrap">
<?php //echo apply_filters( 'the_content', '[facetwp facet="featured"]' ); ?>
</li>
</ul>
</div>
<div class="col-md-4 search-box-container">
<?php echo do_shortcode('[yith_woocommerce_ajax_search]'); ?>
</div>
</div>
<main class='template-page content <?php avia_layout_class( 'content' ); ?> units' <?php avia_markup_helper(array('context' => 'content','post_type'=>'page'));?>>
<?php $avia_config['size'] = avia_layout_class( 'main' , false) == 'entry_without_sidebar' ? '' : 'entry_with_sidebar';
$args = array(
"post_type" => "product",
"post_status" => "publish",
"orderby" => "title",
"order" => "DESC",
"posts_per_page" => '9'
); ?>
<div class="row">
<div class="col-sm-8">
<?php echo apply_filters( 'the_content', '[facetwp template="wc_products"]' ); ?>
</div>
<div class="col-sm-4">
right column sidebar
</div>
</div>
<!--end content-->
</main>
<?php
$avia_config['currently_viewing'] = 'page';
get_sidebar();
?>
</div><!--end container-->
</div><!-- close default .container_wrap element -->
<script>
$(document).ready(function() {
});
var empty = new Array();
$("#filterset").change(function(e){
var currentSelectVal = $(this).val();
console.log('Current Selection: '+currentSelectVal);
if (currentSelectVal == 'all'){
FWP.reset();
} else if (currentSelectVal == 'featured'){
FWP.facets.featured = ['featured'];
FWP.facets.topic = [];
FWP.fetch_data();
} else if (currentSelectVal == 'favorites'){
window.location.href = "<?php echo home_url('favorites/view'); ?>";
} else if (currentSelectVal == 'test'){
console.log('running test');
FWP.facets.topic = ['psychology'];
FWP.facets.featured = [];
FWP.fetch_data();
} else {
console.log('Processing a Topic.');
//FWP.reset();
FWP.facets['featured'] = [];
FWP.facets['topic'] = [currentSelectVal];
FWP.fetch_data();
}
console.log(FWP);
});
(function($) {
window.fwp_is_paging = false;
$(document).on('facetwp-refresh', function() {
if (! window.fwp_is_paging) {
window.fwp_page = 1;
FWP.extras.per_page = 'default';
}
window.fwp_is_paging = false;
});
$(document).on('facetwp-loaded', function() {
window.fwp_total_rows = FWP.settings.pager.total_rows;
if (! FWP.loaded) {
window.fwp_default_per_page = FWP.settings.pager.per_page;
$(window).scroll(function() {
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
var rows_loaded = (window.fwp_page * window.fwp_default_per_page);
if (rows_loaded < window.fwp_total_rows) {
window.fwp_page++;
window.fwp_is_paging = true;
FWP.extras.per_page = (window.fwp_page * window.fwp_default_per_page);
FWP.soft_refresh = true;
FWP.refresh();
}
}
});
}
});
})(jQuery);
</script>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment