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

Changing tabs and display #2

Merged
merged 1 commit into from Nov 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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){
$apiparams[] = $scholarships['meta']['id'].'='.urlencode($_GET['scholarships']).'|'.$scholarships['meta']['id'].'_t='.$scholarships['meta']['type'];
}
//print_r($apiparams);
//if(strlen($apiargs) > 0){
if(count($apiparams) > 0){
$apiargs .= '&params='.implode('|', $apiparams);
}
//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 ) {
$search_results = json_decode($response['body']);

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

'uconn-faculty-led' => 'UConn Faculty-Led',
'exchange-partner' => 'Exchange',
'uconn-faculty-led|exchange-partner' => 'UConn Programs',
//'exchange-partner' => 'Exchange',
//'ct-bw-exchange' => 'CT - BW Exchange',
'3rd-party-direct-enroll' => '3rd Party/Direct Enroll',
'non-uconn' => 'Open to Non-UConn Students',
'' => 'All Programs'
'3rd-party-direct-enroll' => 'Non-UConn Programs',
//'non-uconn' => 'Open to Non-UConn Students',
'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">
Expand All @@ -264,7 +264,11 @@ $programTabIDs = array(

<?php
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' => $num, incorrect way to get shows
);
if(isset($_GET['category']) && strlen($_GET['category']) > 0){
$args['tax_query'] = array(
array(
if(isset($_GET['category']) && strlen($_GET['category']) > 0 && $_GET['category'] != 'all'){
$args['tax_query'] = array();
$category = explode('|', $_GET['category']);
foreach($category as $cat){
$args['tax_query'][] = array(
'taxonomy' => 'category',
'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){
$args['s'] = $_GET['search'];
Expand Down Expand Up @@ -494,9 +502,28 @@ if(($search_results && $search_results->RECORDCOUNT > 0)){
<div class="program-container">
<ul class="program-grid">
<?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
$tags = get_the_tags();
$tags = get_the_tags($post->ID);
$search = array(" ", "/");
$replace = array("", "-");?>
<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));
}
}
?>"> <a href="<?php the_permalink() ?>">
<?php the_post_thumbnail('large');?>
?>"> <a href="<?php echo get_the_permalink($post->ID); ?>">
<?php echo get_the_post_thumbnail($post->ID,'large');?>
<span class="program-name">
<?php the_title(); ?>
<?php echo get_the_title($post->ID); ?>
</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: ?>
<p>
<?php _e('Sorry, no exchange programs are listed.'); ?>
Expand Down