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 #144 from jjc16105/master
People grid layout fix pull request
  • Loading branch information
jmr06005 committed Sep 8, 2016
2 parents dafd775 + a026959 commit c99b491
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 53 deletions.
1 change: 0 additions & 1 deletion functions.php
Expand Up @@ -263,5 +263,4 @@ function uc_redirect_403() {
}

add_action( 'template_redirect', 'uc_redirect_403' );

?>
23 changes: 15 additions & 8 deletions inc/people-grid.php
@@ -1,22 +1,28 @@
<?php
$the_query = new WP_Query( $args );

if ( $the_query->have_posts() ) { ?>
<div class="row">
<?php
$person_count=1;
$persons_per_row = get_field("persons_per_row"); // default is 4
if ( ! $persons_per_row ){
$persons_per_row = 4;
}

//global $post;
//var_dump($post);
//echo "<br />";

$person_count = 1;

while ( $the_query->have_posts() ) {
$the_query->the_post();


/*$persons_per_row = get_field( 'persons_per_row' );
if( empty($persons_per_row) ){
$persons_per_row = 4; // default is 4
}
*/
?>



<?php // 12/$persons_per_row ?>
<div class="col-sm-<?php echo 12/$persons_per_row; ?> personcount-<?php echo $person_count ?>" id="person-<?php echo get_the_id(); ?>">
<div class="person">
<?php
Expand Down Expand Up @@ -133,7 +139,8 @@ if ( $the_query->have_posts() ) { ?>

<?php
// check to see if we need to close this row...
if ($person_count % $persons_per_row == 0){
//if ($person_count % $persons_per_row == 0){
if ( $person_count % $persons_per_row == 0 ){
// if this is the 4th, 8th, 16th, etc person...
echo '</div><!-- /row --><div class="row">';
}
Expand Down
96 changes: 52 additions & 44 deletions user-people.php
@@ -1,8 +1,8 @@
<?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.
* This page template has no padding, and does not display the page title.
* Useful for large images, iframes, or other edge cases.
*/

get_header(); ?>
Expand All @@ -24,31 +24,31 @@ get_header(); ?>
<?php edit_post_link( __( 'Edit', 'cs' ), '<span class="edit-link">', '</span>' ); ?>
</footer><!-- .entry-footer -->
<div class="uc-people">
<?php
<?php
if(! post_password_required()){
// everything we'll be doing will go into the args for WP_query.

// 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',
'meta_key' => 'last_name',
'orderby' => 'menu_order meta_value 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" );

function createTextCell($setting, $field){
global $information_to_display;
if (in_array($setting, $information_to_display)) {
Expand All @@ -57,24 +57,24 @@ get_header(); ?>
echo '</td>';
}
};

function sort_group_by_order( $a, $b ){
function sort_group_by_order( $a, $b ){
// Getting the order for groups $a and $b
$groupA = get_term_by('slug', $a, 'group')->term_id;
$array_orderGroupA = get_option( "taxonomy_{$groupA}" );
$array_orderGroupA = get_option( "taxonomy_{$groupA}" );
$orderGroupA = $array_orderGroupA['group_order'];

$groupB = get_term_by('slug', $b, 'group')->term_id;
$array_orderGroupB = get_option( "taxonomy_{$groupB}" );
$array_orderGroupB = get_option( "taxonomy_{$groupB}" );
$orderGroupB = $array_orderGroupB['group_order'];

$r = strnatcasecmp( $orderGroupA, $orderGroupB );
if( $r === 0 ){
$r = strnatcasecmp( $a, $b );
}
return $r;
return $r;
}

if ($specific_people){
global $specific_people;
global $args;
Expand All @@ -85,20 +85,20 @@ get_header(); ?>
}
$args[post__in]= $post__in;
}

// do we need a tax query?
if ($specific_groups != false || $specific_tags != false){

if ($specific_groups != false || $specific_tags != false){
$tax_query = array();
$isTagSet = false;

$isTagSet = false;
if ($specific_groups != false) {
$group_query = array(
'taxonomy' => 'group',
'field' => 'term_id',
'terms' => $specific_groups
);
array_push($tax_query, $group_query);
array_push($tax_query, $group_query);
}
if ($specific_tags != false) {
$isTagSet = true;
Expand All @@ -110,20 +110,26 @@ get_header(); ?>
array_push($tax_query, $tag_query);
}
$args[tax_query] = $tax_query;


}

$persons_per_row = get_field("persons_per_row"); // default is 4
if ( ! $persons_per_row ){
$persons_per_row = 4;
}

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.
// 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.
// 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;
$id = $value;
Expand All @@ -134,7 +140,7 @@ get_header(); ?>
$slug = $value->slug;
$groups_in_use[$slug]= $slug;
}
};
};
}
if(!empty($specific_groups) && is_array($specific_groups)){
$groups_in_use = array();
Expand All @@ -147,10 +153,12 @@ get_header(); ?>
//sort($groups_in_use);
usort($groups_in_use, 'sort_group_by_order' );

// 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.


// 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.
// 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',
Expand All @@ -161,34 +169,34 @@ get_header(); ?>
if( $isTagSet != false ){
array_push($tax_query, $tag_query);
}
$args['tax_query'] = $tax_query;
$args['tax_query'] = $tax_query;

// with $arg updated, let's do a new 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-## -->
Expand Down

0 comments on commit c99b491

Please sign in to comment.