This repository has been archived by the owner. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
andrewmbacon
committed
Nov 2, 2015
1 parent
9a744ce
commit d5909cb
Showing
1 changed file
with
190 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,190 +1,190 @@ | ||
<?php | ||
/** | ||
Template Name: People | ||
* This page template has no padding, and does not display the page title. | ||
* Useful for large images, iframes, or other edge cases. | ||
*/ | ||
|
||
get_header(); ?> | ||
<div id="page-userlist"> | ||
<?php include('inc/sidebar-check.php')?> | ||
<?php while ( have_posts() ) : the_post(); ?> | ||
<?php include('inc/submenu-check.php')?> | ||
<div class="row"> | ||
<div class="col-sm-<?php echo (is_active_sidebar( $sidebar )?9:12); ?>"> | ||
<div id="primary" class="content-area"> | ||
<main id="main" class="site-main" role="main"> | ||
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?>> | ||
<header class="entry-header"> | ||
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?> | ||
</header><!-- .entry-header --> | ||
<div class="entry-content"> | ||
<?php the_content(); ?> | ||
<div class="uc-people"> | ||
<?php | ||
// everything we'll be doing will go into the args for WP_query. | ||
//$args = array('post_type=person'); | ||
$args = array( | ||
'posts_per_page' => -1, | ||
'post_type' => 'person', | ||
'orderby' => 'menu_order title', | ||
'order' => 'ASC', | ||
); | ||
|
||
|
||
|
||
// Settings | ||
|
||
$layout = get_field( "layout" ); | ||
$people_to_display = get_field( "people_to_display" ); | ||
$break_into_groups = get_field( "break_into_groups" ); | ||
$specific_people = get_field( "specific_people" ); | ||
$specific_groups = get_field( "specific_groups" ); | ||
$specific_tags = get_field( "specific_tags" ); | ||
$information_to_display = get_field( "information_to_display" ); | ||
|
||
//var_dump($specific_people); | ||
|
||
function createTextCell($setting, $field){ | ||
global $information_to_display; | ||
if (in_array($setting, $information_to_display)) { | ||
echo '<td class="person-title">'; | ||
the_field($field); | ||
echo '</td>'; | ||
} | ||
}; | ||
|
||
|
||
|
||
if ($specific_people){ | ||
global $specific_people; | ||
global $args; | ||
$post__in = array(); | ||
foreach($specific_people as &$value){ | ||
array_push($post__in, $value->ID); | ||
} | ||
$args[post__in]= $post__in; | ||
} | ||
|
||
// do we need a tax query? | ||
if ($specific_groups != false || $specific_tags != false){ | ||
$tax_query = array(); | ||
if ($specific_groups != false) { | ||
$group_query = array( | ||
'taxonomy' => 'group', | ||
'field' => 'term_id', | ||
'terms' => $specific_groups | ||
); | ||
array_push($tax_query, $group_query); | ||
} | ||
if ($specific_tags != false) { | ||
$tag_query = array( | ||
'taxonomy' => 'persontag', | ||
'field' => 'term_id', | ||
'terms' => $specific_tags | ||
); | ||
array_push($tax_query, $tag_query); | ||
} | ||
$args[tax_query] = $tax_query; | ||
|
||
} | ||
if ($break_into_groups == 1 ){ | ||
//echo '<h1>Break into Groups</h1>'; | ||
// get all the people | ||
$the_query = new WP_Query( $args ); | ||
|
||
// focusing on just the people, not the rest of the query. | ||
$people = $the_query->posts; | ||
|
||
// look at each person, and see each group used, use that to create a list of terms. | ||
$groups_in_use = array(); | ||
|
||
foreach($people as $value){ | ||
$id = $value->ID; | ||
$terms = get_the_terms($id, 'group'); | ||
if (is_array($terms)){ | ||
foreach($terms as $key => $value){ | ||
//duplicates will overwrite themselves... | ||
$slug = $value->slug; | ||
$groups_in_use[$slug]= $slug; | ||
} | ||
}; | ||
} | ||
|
||
// sort the groups in use alphabetically | ||
sort($groups_in_use); | ||
|
||
// for each item in the list of terms, do a new query, but this time we're going to limit it to ONLY items from that one group. | ||
foreach($groups_in_use as $value){ | ||
// this sets up the query we'll need, and will overwrite any group queries from the original settings. | ||
$tax_query = array(); | ||
$group_query = array( | ||
'taxonomy' => 'group', | ||
'field' => 'slug', | ||
'terms' => $value | ||
); | ||
array_push($tax_query, $group_query); | ||
$args['tax_query'] = $tax_query; | ||
|
||
// with $arg updated, let's do a new query. | ||
echo '<h3 class="group-title">'.get_term_by('slug', $value, 'group')->name.'</h3>'; | ||
if ($layout == 'grid') { | ||
include('inc/people-grid.php'); | ||
} | ||
if ($layout == 'table') { | ||
include('inc/people-table.php'); | ||
} | ||
} | ||
|
||
} else { | ||
|
||
if ($layout == 'grid') { | ||
include('inc/people-grid.php'); | ||
} | ||
if ($layout == 'table') { | ||
include('inc/people-table.php'); | ||
} | ||
|
||
} | ||
?> | ||
|
||
|
||
</div> | ||
</div><!-- .entry-content --> | ||
<footer class="entry-footer"> | ||
<?php edit_post_link( __( 'Edit', 'cs' ), '<span class="edit-link">', '</span>' ); ?> | ||
</footer><!-- .entry-footer --> | ||
</article><!-- #post-## --> | ||
</main> | ||
</div> | ||
</div> | ||
<?php include('inc/sidebar-if-active.php')?> | ||
</div> | ||
<?php include('inc/submenu-closing-tags.php')?> | ||
<?php endwhile; // end of the loop. ?> | ||
</div> | ||
<script type="application/javascript"> | ||
function adjustImages(){ | ||
jQuery('.person-image').each(function(index, element) { | ||
var imgWidth = jQuery(this).find('img').width(); | ||
var imgHeight = jQuery(this).find('img').height(); | ||
var width = jQuery(this).width(); | ||
//jQuery(this).height(width); | ||
jQuery(this).css('display', 'block'); | ||
}); | ||
}; | ||
jQuery(window).resize(function() { | ||
adjustImages(); | ||
}); | ||
jQuery(window).load(function() { | ||
adjustImages(); | ||
}); | ||
</script> | ||
<?php get_footer(); ?> | ||
<?php | ||
/** | ||
Template Name: People | ||
* This page template has no padding, and does not display the page title. | ||
* Useful for large images, iframes, or other edge cases. | ||
*/ | ||
|
||
get_header(); ?> | ||
<div id="page-userlist"> | ||
<?php include('inc/sidebar-check.php')?> | ||
<?php while ( have_posts() ) : the_post(); ?> | ||
<?php include('inc/submenu-check.php')?> | ||
<div class="row"> | ||
<div class="col-sm-<?php echo (is_active_sidebar( $sidebar )?9:12); ?>"> | ||
<div id="primary" class="content-area"> | ||
<main id="main" class="site-main" role="main"> | ||
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?>> | ||
<header class="entry-header"> | ||
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?> | ||
</header><!-- .entry-header --> | ||
<div class="entry-content"> | ||
<?php the_content(); ?> | ||
<footer class="entry-footer"> | ||
<?php edit_post_link( __( 'Edit', 'cs' ), '<span class="edit-link">', '</span>' ); ?> | ||
</footer><!-- .entry-footer --> | ||
<div class="uc-people"> | ||
<?php | ||
// everything we'll be doing will go into the args for WP_query. | ||
|
||
//$args = array('post_type=person'); | ||
$args = array( | ||
'posts_per_page' => -1, | ||
'post_type' => 'person', | ||
'orderby' => 'menu_order title', | ||
'order' => 'ASC', | ||
); | ||
|
||
|
||
|
||
// Settings | ||
|
||
$layout = get_field( "layout" ); | ||
$people_to_display = get_field( "people_to_display" ); | ||
$break_into_groups = get_field( "break_into_groups" ); | ||
$specific_people = get_field( "specific_people" ); | ||
$specific_groups = get_field( "specific_groups" ); | ||
$specific_tags = get_field( "specific_tags" ); | ||
$information_to_display = get_field( "information_to_display" ); | ||
|
||
//var_dump($specific_people); | ||
|
||
function createTextCell($setting, $field){ | ||
global $information_to_display; | ||
if (in_array($setting, $information_to_display)) { | ||
echo '<td class="person-title">'; | ||
the_field($field); | ||
echo '</td>'; | ||
} | ||
}; | ||
|
||
|
||
|
||
if ($specific_people){ | ||
global $specific_people; | ||
global $args; | ||
$post__in = array(); | ||
foreach($specific_people as &$value){ | ||
array_push($post__in, $value->ID); | ||
} | ||
$args[post__in]= $post__in; | ||
} | ||
|
||
// do we need a tax query? | ||
if ($specific_groups != false || $specific_tags != false){ | ||
|
||
$tax_query = array(); | ||
if ($specific_groups != false) { | ||
$group_query = array( | ||
'taxonomy' => 'group', | ||
'field' => 'term_id', | ||
'terms' => $specific_groups | ||
); | ||
array_push($tax_query, $group_query); | ||
} | ||
if ($specific_tags != false) { | ||
$tag_query = array( | ||
'taxonomy' => 'persontag', | ||
'field' => 'term_id', | ||
'terms' => $specific_tags | ||
); | ||
array_push($tax_query, $tag_query); | ||
} | ||
$args[tax_query] = $tax_query; | ||
|
||
} | ||
if ($break_into_groups == 1 ){ | ||
//echo '<h1>Break into Groups</h1>'; | ||
|
||
// get all the people | ||
$the_query = new WP_Query( $args ); | ||
|
||
// focusing on just the people, not the rest of the query. | ||
$people = $the_query->posts; | ||
|
||
// look at each person, and see each group used, use that to create a list of terms. | ||
$groups_in_use = array(); | ||
|
||
foreach($people as $value){ | ||
$id = $value->ID; | ||
$terms = get_the_terms($id, 'group'); | ||
if (is_array($terms)){ | ||
foreach($terms as $key => $value){ | ||
//duplicates will overwrite themselves... | ||
$slug = $value->slug; | ||
$groups_in_use[$slug]= $slug; | ||
} | ||
}; | ||
} | ||
|
||
// sort the groups in use alphabetically | ||
sort($groups_in_use); | ||
|
||
// for each item in the list of terms, do a new query, but this time we're going to limit it to ONLY items from that one group. | ||
foreach($groups_in_use as $value){ | ||
|
||
// this sets up the query we'll need, and will overwrite any group queries from the original settings. | ||
$tax_query = array(); | ||
$group_query = array( | ||
'taxonomy' => 'group', | ||
'field' => 'slug', | ||
'terms' => $value | ||
); | ||
array_push($tax_query, $group_query); | ||
$args['tax_query'] = $tax_query; | ||
|
||
// with $arg updated, let's do a new query. | ||
echo '<h3 class="group-title">'.get_term_by('slug', $value, 'group')->name.'</h3>'; | ||
|
||
if ($layout == 'grid') { | ||
include('inc/people-grid.php'); | ||
} | ||
if ($layout == 'table') { | ||
include('inc/people-table.php'); | ||
} | ||
} | ||
|
||
} else { | ||
|
||
if ($layout == 'grid') { | ||
include('inc/people-grid.php'); | ||
} | ||
if ($layout == 'table') { | ||
include('inc/people-table.php'); | ||
} | ||
} | ||
?> | ||
</div> | ||
</div><!-- .entry-content --> | ||
</article><!-- #post-## --> | ||
</main> | ||
</div> | ||
</div> | ||
<?php include('inc/sidebar-if-active.php')?> | ||
</div> | ||
<?php include('inc/submenu-closing-tags.php')?> | ||
<?php endwhile; // end of the loop. ?> | ||
</div> | ||
<script type="application/javascript"> | ||
function adjustImages(){ | ||
jQuery('.person-image').each(function(index, element) { | ||
var imgWidth = jQuery(this).find('img').width(); | ||
var imgHeight = jQuery(this).find('img').height(); | ||
var width = jQuery(this).width(); | ||
//jQuery(this).height(width); | ||
jQuery(this).css('display', 'block'); | ||
}); | ||
}; | ||
jQuery(window).resize(function() { | ||
adjustImages(); | ||
}); | ||
jQuery(window).load(function() { | ||
adjustImages(); | ||
}); | ||
</script> | ||
<?php get_footer(); ?> |