Skip to content

Instantly share code, notes, and snippets.

@mopuriiswaryalakshmi
Created July 13, 2018 07:10
Show Gist options
  • Save mopuriiswaryalakshmi/38e5ae053be4a898802578c637d3d474 to your computer and use it in GitHub Desktop.
Save mopuriiswaryalakshmi/38e5ae053be4a898802578c637d3d474 to your computer and use it in GitHub Desktop.
<?php get_header()?>
<?php $contact_numbers_data = contactPhoneNumbers(); ?>
<script type="text/javascript">
$(document).ready(function(){
$('ul.blog_categories a').click(function(){
var selected_category = $(this).text();
<?php
echo "var blog_url='".get_page_link( get_page_by_title( 'whatsNew' )->ID )."';";
?>
if(selected_category == "Most Recent"){
return window.location = blog_url; //URL OF CURRENT PAGE
}else{
return window.location = blog_url+"?type="+selected_category;
}
});
});
</script>
<!-- whatsnew_category -->
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<?php echo home_url('/')?>">Home</a></li>
<?php
if($_GET["type"]){ ?>
<li class="breadcrumb-item active"><?php echo $_GET['type'] ?></li>
<?php
} else { ?>
<li class="breadcrumb-item active">Most Recent</li>
<?php
} ?>
</ol>
<section class="whats-new py-60">
<div class="container">
<h2 class="text-danger text-center dealer-heading mb-0">what’s new</h2>
<ul class="nav nav-pills py-60 blog_categories">
<?php if($_GET["type"]) { ?>
<a class="nav-link" href="#mostRecent" data-toggle="pill">Most Recent</a>
<?php }else{ ?>
<a class="nav-link active" href="#mostRecent" data-toggle="pill">Most Recent</a>
<?php } ?>
<?php
$whatsnew_category_pod = pods('whatsnew_category');
$params = array(
"select" => "*, category_name.name"
);
$whatsnew_category_pod->find($params,$limit=-1);
$whatsnew_category_data = $whatsnew_category_pod->data();
foreach ($whatsnew_category_data as $key => $all_categories) {
if($_GET["type"] == $all_categories->{"name"}){ ?>
<a class="nav-link active" href="#<?php echo $all_categories->{"name"} ?>" id="" data-toggle="pill"><?php echo $all_categories->{"name"} ?></a>
<?php }else{ ?>
<a class="nav-link" href="#<?php echo $all_categories->{"name"} ?>" id="" data-toggle="pill"><?php echo $all_categories->{"name"} ?></a>
<?php }
}
?>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<?php
if($_GET["type"]){ ?>
<div class="tab-pane active" id="<?php echo $_GET['type'] ?>" role="tabpanel">
<?php
} else { ?>
<div class="tab-pane active" id="mostRecent" role="tabpanel">
<?php
} ?>
<div class="card-columns">
<?php
$categories = post_categories();
$domain_name = $_SERVER["SERVER_NAME"];
// $domain_name = getDomainData()->domain_name;
// echo $domain_name;
$post_pod = pods('post');
$type = isset($_GET["type"]) ? "'".$_GET['type']."'" : $categories;
$params = array('limit' => 5,
"where" => "domain_name.name = '$domain_name' and category.name IN ($type)",
"orderby" => "t.post_date DESC",
);
// print_r($params);
$post_pod->find($params);
$post_data = $post_pod->data();
if($post_data){
foreach ($post_data as $key => $all_posts) {
$post_id = $all_posts->ID; //This is Post ID
$post_image_id= get_post_meta( $post_id, 'image', true);
$video = get_post_meta($all_posts->ID, 'video', true);
$embed_code = wp_oembed_get($video, array('width'=>1010));
$blog_image=pods_image_url( $post_image_id, $size = null, $default = 0, $force = false );
$whats_new_url = get_page_link( get_page_by_title( 'whatsNewBlog' )->ID );
$post_title = $all_posts->{"post_title"};
if($_GET["type"]){
$specific_whatsnew_url = $whats_new_url ."?postId=".urlencode($post_id)."&"."type=".urlencode($_GET['type']);
}else{
$specific_whatsnew_url = $whats_new_url ."?postId=".urlencode($post_id)."&"."blogType=".urlencode('Most Recent');
}
?>
<?php if($embed_code){
echo $embed_code ;
?>
<?php }else{ ?>
<div class="card">
<img class="card-img-top img-fluid" src="<?php echo $blog_image ?>" alt="Card image cap">
<?php }?>
<div class="row blog-share-date">
<div class="col-sm-6"><span><?php echo date('F j, Y', strtotime($all_posts->{"post_date"})) ?></span></div>
<div class="col-sm-6 text-right">
<span class="sharelist">
<img src="<?php bloginfo('template_url'); ?>/images/icons/icon_share.svg" alt="share" height="19px" class="mr-2">
<div class="share-container">
<ul class="list-unstyled mb-0">
<li class="py-2"><a href="javascript:fb_shareCurrentPage()" target="_blank" alt="Share on Facebook"><img class="d-inline-flex" src="<?php bloginfo('template_url'); ?>/images/icons/icon_facebook_share.svg" alt="fb" height="28px"></a></li>
<li class="py-2"><a class="tweet" href="javascript:tweet_shareCurrentPage()" target="_blank" alt="Tweet this page"><img src="<?php bloginfo('template_url'); ?>/images/icons/icon_twitter_share.svg" alt="fb" height="28px"></a></li>
<li class="py-2"><a class="" href="javascript:googlePlus_shareCurrentPage()" target="_blank" alt="GooglePlus Share" style="background: no-repeat scroll left center transparent;"><img class="" src="<?php bloginfo('template_url'); ?>/images/icons/icon_g+_share.svg" alt="GooglePlus+" height="28px"></a></li>
</ul>
</div>
</span>
</div>
</div>
<div class="card-block">
<h4 class="card-title blog-header"><?php echo $all_posts->{"post_title"}?></h4>
<p class="card-text"><?php echo $all_posts->{"shot_description"} ?></p>
<a href="<?php echo $specific_whatsnew_url ?>" class="btn btn-danger text-white">Read More</a>
</div>
</div>
<?php
}
}
?>
</div>
</div><!-- most recent tab -->
</div> <!-- tab content -->
</div><!-- container -->
</section>
<hr class="divder my-0">
<?php
echo $post_pod->pagination(array( 'type' => 'advanced','label' => 'Go to page','show_label' => true, ));
//These are the pagination links to be shown.
?>
<section class="bg-grey py-60">
<h2 class="text-danger dealer-heading text-center mt-0 mb-2">Questions?</h2>
<p class="text-center mb-5">Don’t hesitate. Call now!</p>
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-6 d-inline-flex justify-content-center">
<div class="media">
<img class="d-flex align-self-center mr-3" src="<?php bloginfo('template_url'); ?>/images/icons/icon_call.svg" height="36px" alt="Generic placeholder image">
<div class="media-body">
<p class="mb-0">For Customer Service</p>
<h5 class="toll-free-number my-0 text-danger"><?php echo $contact_numbers_data[0]->{"customer_service_no"} ?></h5>
</div>
</div>
</div>
<div class="col-xs-12 col-md-6 d-inline-flex justify-content-center">
<div class="media">
<img class="d-flex align-self-center mr-3" src="<?php bloginfo('template_url'); ?>/images/icons/icon_call.svg" height="36px" alt="Generic placeholder image">
<div class="media-body">
<p class="mb-0">For Sales Representative</p>
<h5 class="toll-free-number my-0 text-danger"><?php echo $contact_numbers_data[0]->{"sales_rep_no"} ?></h5>
</div>
</div>
</div>
</div>
</div>
</section>
<hr class="divider my-0">
<?php get_footer()?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment