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

Commit

Permalink
User template completed
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmbacon committed Aug 7, 2015
1 parent d1717ac commit 2ac39db
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 64 deletions.
12 changes: 6 additions & 6 deletions inc/people-grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@

if (in_array('first', $information_to_display) || in_array('middle', $information_to_display) || in_array('last', $information_to_display)){
echo '<h4 class="person-name">';
if (in_array('first', $information_to_display)) {
if (in_array('first_name', $information_to_display)) {
the_field('first_name');
echo ' ';
};
if (in_array('middle', $information_to_display)) {
if (in_array('middle_name', $information_to_display)) {
the_field('middle_name');
echo ' ';
};
if (in_array('last', $information_to_display)) {
if (in_array('last_name', $information_to_display)) {
the_field('last_name');
};
echo '</h4>';
Expand All @@ -56,7 +56,7 @@
the_field('about');
echo '</div>';
};
if (in_array('link', $information_to_display)) {
if (in_array('file', $information_to_display)) {
echo '<p class="person-file">';
$file = get_field('file');
//var_dump($thing);
Expand All @@ -73,7 +73,7 @@
the_field('phone');
echo '</p>';
};
if (in_array('phonealt', $information_to_display)) {
if (in_array('phone_(alternate)', $information_to_display)) {
echo '<p class="person-phone_(alternate)">';
the_field('phone_(alternate)');
echo '</p>';
Expand All @@ -83,7 +83,7 @@
the_field('fax');
echo '</p>';
};
if (in_array('mail', $information_to_display)) {
if (in_array('mailing_address', $information_to_display)) {
echo '<p class="person-mailing_address">';
the_field('mailing_address');
echo '</p>';
Expand Down
37 changes: 17 additions & 20 deletions inc/people-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// how many columns? Based on what they chose to display.

$num_cols = count($information_to_display);
var_dump($num_cols);
//var_dump($num_cols);

?>
<table class="table table-striped">
Expand All @@ -15,31 +15,28 @@
<?php
$nameCell = false;
foreach($information_to_display as $value){
if ($value == 'first' || $value == 'middle' || $value == 'last'){
if ($value == 'first_name' || $value == 'middle_name' || $value == 'last_name'){
if ($nameCell == false){
echo '<th>Name</th>';
$nameCell = true;
};
} elseif ($value == 'photo') {
echo '<th>&nbsp;</th>';
} else {
echo '<th>'.$value.'</th>';
//var_dump(get_field_object('field_'.$value));
$arr = get_field_object('field_'.$value);
$label = $arr['label'];
echo '<th>'.$label.'</th>';
}
}
?>
</tr>
</thead>
<tbody>
<?php
var_dump($information_to_display);
echo '<hr>';
//var_dump($information_to_display);


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>';
}
};

while ( $the_query->have_posts() ) {
$the_query->the_post();
Expand Down Expand Up @@ -69,24 +66,24 @@ function createTextCell($setting, $field){
the_post_thumbnail(array('65', '65'));
echo '</a></td>';
}
if (in_array('first', $information_to_display) || in_array('middle', $information_to_display) || in_array('last', $information_to_display)){
if (in_array('first_name', $information_to_display) || in_array('middle_name', $information_to_display) || in_array('last_name', $information_to_display)){
echo '<td class="person-name"><a href="'.get_the_permalink().'">';
if (in_array('first', $information_to_display)) {
if (in_array('first_name', $information_to_display)) {
the_field('first_name');
echo ' ';
};
if (in_array('middle', $information_to_display)) {
if (in_array('middle_name', $information_to_display)) {
the_field('middle_name');
echo ' ';
};
if (in_array('last', $information_to_display)) {
if (in_array('last_name', $information_to_display)) {
the_field('last_name');
};
echo '</a></td>';
}
createTextCell('title', 'title');
createTextCell('about', 'about');
if (in_array('link', $information_to_display)) {
if (in_array('file', $information_to_display)) {
echo '<td class="person-file">';
$file = get_field('file');
echo '<a href="'.$file[url].'">'.$file[title].'</a>';
Expand All @@ -98,9 +95,9 @@ function createTextCell($setting, $field){
echo '</td>';
};
createTextCell('phone', 'phone');
createTextCell('phonealt', 'phone_(alternate)');
createTextCell('phone_(alternate)', 'phone_(alternate)');
createTextCell('fax', 'fax');
createTextCell('mail', 'mailing_address');
createTextCell('mailing_address', 'mailing_address');
createTextCell('office_location', 'office_location');
createTextCell('office_hours', 'office_hours');
createTextCell('courses', 'courses');
Expand Down
37 changes: 37 additions & 0 deletions single-person.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* The Template for displaying all single posts.
*
* @package cornerstone
*/

get_header(); ?>
<div id="page-single">
<div class="row">
<div class="col-md-9">

<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">

<?php while ( have_posts() ) : the_post(); ?>

<?php get_template_part( 'content', 'single' ); ?>

<?php cs_post_nav(); ?>

<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
?>

<?php endwhile; // end of the loop. ?>

</main><!-- #main -->
</div><!-- #primary -->
</div>
<?php get_sidebar(); ?>
</div>
</div>
<?php get_footer(); ?>
102 changes: 64 additions & 38 deletions user-people.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@
$specific_tags = get_field( "specific_tags" );
$information_to_display = get_field( "information_to_display" );

var_dump($specific_people);
//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>';
}
};



Expand Down Expand Up @@ -83,59 +92,76 @@

}
if ($break_into_groups == 1 ){
echo '<h1>Break into Groups</h1>';
//echo '<h1>Break into Groups</h1>';

// get all the people
$the_query = new WP_Query( $args );

print_r($the_query->posts);
echo '<hr>';
// focusing on jus the people, not the rest of the query.
//print_r($the_query->posts);
//echo '<hr>';
// focusing on just the people, not the rest of the query.
$people = $the_query->posts;
// look at each person, and see each group used.

// 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;
echo '<br/>';
$terms = get_the_terms($id, 'group');
var_dump($terms);
foreach($terms as $value){
//duplicates will overwrite themselves...
$slug = $value->slug;
$groups_in_use[$slug]= $slug;
}
//var_dump($groups_in_use);
}
/**/

echo '<hr>';
// sort the groups in use alphabetically
sort($groups_in_use);

var_dump($the_query);
/*
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
//$the_query->posts;
//the_title();
// 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.
echo '<hr>';
//var_dump($args);
foreach($groups_in_use as $value){

//echo $value;
//echo '<br/>';

// 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');
}
};
*/

// get all the people (after they've beeen filtered down)

// check those people for groups (don;t want to be listing groups we won;t use)
// Create a list for each group.
if ($layout == 'table') {
include('inc/people-table.php');
}
echo '<hr>';
}

} else {

// display all people that belong to that group.
if ($layout == 'grid') {
include('inc/people-grid.php');
}
if ($layout == 'table') {
include('inc/people-table.php');
}

}
/*
if ($layout == 'grid') {
include('inc/people-grid.php');
}
if ($layout == 'list') {
include('inc/people-list.php');
}
if ($layout == 'table') {
include('inc/people-table.php');
}
*/


?>
<hr/>

Expand Down

0 comments on commit 2ac39db

Please sign in to comment.