Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2 from jmr06005/master
Changing tabs and display
  • Loading branch information
jmr06005 committed Nov 22, 2017
2 parents d884697 + d6d9501 commit 1640dbe
Showing 1 changed file with 60 additions and 20 deletions.
80 changes: 60 additions & 20 deletions templates/archive-programs.php
Expand Up @@ -224,18 +224,17 @@ if(isset($_GET['sponsorship']) && strlen($_GET['sponsorship']) > 0){
if(isset($_GET['scholarships']) && strlen($_GET['scholarships']) > 0){ if(isset($_GET['scholarships']) && strlen($_GET['scholarships']) > 0){
$apiparams[] = $scholarships['meta']['id'].'='.urlencode($_GET['scholarships']).'|'.$scholarships['meta']['id'].'_t='.$scholarships['meta']['type']; $apiparams[] = $scholarships['meta']['id'].'='.urlencode($_GET['scholarships']).'|'.$scholarships['meta']['id'].'_t='.$scholarships['meta']['type'];
} }
//print_r($apiparams);
//if(strlen($apiargs) > 0){ //if(strlen($apiargs) > 0){
if(count($apiparams) > 0){ if(count($apiparams) > 0){
$apiargs .= '&params='.implode('|', $apiparams); $apiargs .= '&params='.implode('|', $apiparams);
} }
//echo '<a href="'.$api.$apiargs.'">here</a>'; //echo '<a href="'.$api.$apiargs.'">here</a>';
$response = wp_remote_get( $api.$apiargs ); $response = wp_remote_get( $api.$apiargs, array('timeout' => 10) );
if( is_array($response) && isset($response['body']) && strlen($response['body']) > 0 ) { if( is_array($response) && isset($response['body']) && strlen($response['body']) > 0 ) {
$search_results = json_decode($response['body']); $search_results = json_decode($response['body']);


} }
//print_r($search_results); //print_r($response);
//} //}
?> ?>
<?php get_header(); ?> <?php get_header(); ?>
Expand All @@ -245,13 +244,14 @@ if(isset($_GET['scholarships']) && strlen($_GET['scholarships']) > 0){
<?php <?php
$programTabIDs = array( $programTabIDs = array(


'uconn-faculty-led' => 'UConn Faculty-Led', 'uconn-faculty-led|exchange-partner' => 'UConn Programs',
'exchange-partner' => 'Exchange', //'exchange-partner' => 'Exchange',
//'ct-bw-exchange' => 'CT - BW Exchange', //'ct-bw-exchange' => 'CT - BW Exchange',
'3rd-party-direct-enroll' => '3rd Party/Direct Enroll', '3rd-party-direct-enroll' => 'Non-UConn Programs',
'non-uconn' => 'Open to Non-UConn Students', //'non-uconn' => 'Open to Non-UConn Students',
'' => 'All Programs' 'all' => 'All Programs'
); );
if(!isset($_GET['category']) || strlen($_GET['category']) == 0 || !isset($programTabIDs[$_GET['category']])) $_GET['category'] = 'uconn-faculty-led|exchange-partner';
?> ?>


<section id="program-container" class="program-content clearfix"> <section id="program-container" class="program-content clearfix">
Expand All @@ -264,7 +264,11 @@ $programTabIDs = array(


<?php <?php
foreach( $programTabIDs as $id => $title ){ foreach( $programTabIDs as $id => $title ){
echo '<a type="button" class="btn btn-default'.((isset($_GET['category']) && $_GET['category'] == $id ) || (strlen($id) ==0 && (!isset($_GET['category'])||strlen($_GET['category']) == 0))? ' active': '' ).'" href="?category='.$id.'">'.$title.'</a>'; echo '<a type="button" class="btn btn-default';
if(isset($_GET['category']) && strstr($id, $_GET['category'])){
echo ' active';
}
echo '" href="?category='.$id.'">'.$title.'</a>';
} }
?> ?>


Expand Down Expand Up @@ -448,13 +452,17 @@ if(($search_results && $search_results->RECORDCOUNT > 0)){
'posts_per_page' => -1 'posts_per_page' => -1
//'posts_per_page' => $num, incorrect way to get shows //'posts_per_page' => $num, incorrect way to get shows
); );
if(isset($_GET['category']) && strlen($_GET['category']) > 0){ if(isset($_GET['category']) && strlen($_GET['category']) > 0 && $_GET['category'] != 'all'){
$args['tax_query'] = array( $args['tax_query'] = array();
array( $category = explode('|', $_GET['category']);
foreach($category as $cat){
$args['tax_query'][] = array(
'taxonomy' => 'category', 'taxonomy' => 'category',
'field' => 'slug', 'field' => 'slug',
'terms' => $_GET['category'] 'terms' => $cat
)); );
}
if(count($args['tax_query']) > 1) $args['tax_query']['relation'] = 'OR';
} }
if(isset($_GET['search']) && strlen($_GET['search']) > 0){ if(isset($_GET['search']) && strlen($_GET['search']) > 0){
$args['s'] = $_GET['search']; $args['s'] = $_GET['search'];
Expand Down Expand Up @@ -494,9 +502,28 @@ if(($search_results && $search_results->RECORDCOUNT > 0)){
<div class="program-container"> <div class="program-container">
<ul class="program-grid"> <ul class="program-grid">
<?php <?php
if(!empty($posts)): foreach($posts as $post): setup_postdata($post); ?> if(!empty($posts)):
$groups = array();
foreach($programTabIDs as $key => $val){
$groups[$key] = array();
}
foreach($posts as $post){
foreach($programTabIDs as $key => $val){
foreach(get_the_category($post->ID) as $category){
if(strstr($key,$category->slug)){
$groups[$key][] = $post;
}
}
}
}
//print_r($groups);

//exit;
function display($posts = array()){
foreach($posts as $post){
?>
<?php <?php
$tags = get_the_tags(); $tags = get_the_tags($post->ID);
$search = array(" ", "/"); $search = array(" ", "/");
$replace = array("", "-");?> $replace = array("", "-");?>
<li class="program-box<?php <li class="program-box<?php
Expand Down Expand Up @@ -535,12 +562,25 @@ if(($search_results && $search_results->RECORDCOUNT > 0)){
echo ' '.strtolower(str_replace($search, $replace, $tag->name)); echo ' '.strtolower(str_replace($search, $replace, $tag->name));
} }
} }
?>"> <a href="<?php the_permalink() ?>"> ?>"> <a href="<?php echo get_the_permalink($post->ID); ?>">
<?php the_post_thumbnail('large');?> <?php echo get_the_post_thumbnail($post->ID,'large');?>
<span class="program-name"> <span class="program-name">
<?php the_title(); ?> <?php echo get_the_title($post->ID); ?>
</span> </a> </li> </span> </a> </li>
<?php endforeach;?> <?php }
} // end function display
if($_GET['category'] == 'all'){
foreach($groups as $key=>$group){
if($key == 'all') continue;
echo '<h2 style="clear:left">'.$programTabIDs[$key].'</h2>';
display($group);
}
}
else{
echo '<h2 style="clear:left">'.$programTabIDs[$_GET['category']].'</h2>';
display($posts);
}
?>
<?php else: ?> <?php else: ?>
<p> <p>
<?php _e('Sorry, no exchange programs are listed.'); ?> <?php _e('Sorry, no exchange programs are listed.'); ?>
Expand Down

0 comments on commit 1640dbe

Please sign in to comment.