Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
neag/page_people.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
116 lines (100 sloc)
4.3 KB
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
<?php | |
/** | |
* Template Name: Directory | |
*/ | |
get_header(); ?> | |
<div id="page-people"> | |
<?php include get_template_directory().'/inc/sidebar-check.php';?> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<?php include get_template_directory().'/inc/submenu-check.php';?> | |
<h1 class="page-title"><?php the_title(); ?></h1> | |
<div class="row"> | |
<div class="col-sm-<?php echo (is_active_sidebar( $sidebar )?9:12); ?>"> | |
<?php get_template_part( 'content', 'blank' ); ?> | |
<?php | |
$args = array( | |
'post_type' => array( 'person' ), | |
'fields' => 'ids', | |
'posts_per_page' => -1, | |
); | |
$query = new WP_Query( $args ); | |
$people = $query->posts; | |
usort( $people, 'neag_sort_by_last_then_first' ); | |
ob_start(); | |
?> | |
<div id="directory-dropdown" class="form-group clearfix"> | |
<div class="col-sm-5"> | |
<select id="directory-dropdownMenu" class="form-control"> | |
<option class="directory-dropdownItem" value="0">All Faculty & Staff</option> | |
<?php | |
$categories = get_terms( 'group' ); | |
foreach( $categories as $c ){ | |
echo "<option class='directory-dropdownItem' value='{$c->term_id}'>{$c->name}</option>"; | |
} | |
?> | |
</select> | |
</div> | |
</div> | |
<?php | |
$dropdown = ob_get_clean(); | |
echo $dropdown; | |
$fields = array( 'first_name' => '', 'middle_name' => '', 'last_name' => '', 'title' => '', 'email' => '', 'phone' => '', | |
'office_location' => '' ); | |
$alphabet = array_fill_keys( range('A', 'Z'), '' ); | |
echo "<div class='directory-anchor-nav'>"; | |
foreach( $alphabet as $k=>$v ){ | |
echo "<a href='#{$k}'>{$k}</a> "; | |
} | |
echo "</div>"; | |
echo "<span id='directory-list-loading-image' style='display:none'></span>"; | |
echo "<span id='directory-list-loading-text' style='display:none'>Loading...</span>"; | |
echo "<div id='directory-list'>"; | |
foreach( $people as $p ){ | |
foreach( $fields as $k=>$v ){ | |
$fields[$k] = get_field( $k, $p ); | |
} | |
$nameLetter = substr( $fields['last_name'], 0, 1 ); | |
$setDivIDFlag = false; | |
if( empty( $alphabet[$nameLetter] ) ){ | |
$setDivIDFlag = true; | |
$alphabet[$nameLetter] = true; | |
} | |
ob_start(); | |
$setDivID = ''; | |
if( $setDivIDFlag == true ){ | |
$setDivID = " id='{$nameLetter}'"; | |
} | |
$emailAddress = antispambot(str_replace('&#039','\'', $fields['email'])); | |
$permalink = get_permalink( $p ); | |
echo "<div{$setDivID} class='directory-person'>"; | |
echo "<div class='row'>"; | |
echo "<div class='col-sm-5 directory-face-wrap'>"; | |
echo "<div class='directory-photo'><a href='{$permalink}'>".get_the_post_thumbnail( $p, array(115, 115) ).'</a></div>'; | |
echo "<div class='directory-name-title-wrap'>"; | |
echo "<div class='directory-name'><a href='{$permalink}'>{$fields['first_name']} {$fields['middle_name']} {$fields['last_name']}</a></div>"; | |
echo "<div class='directory-title'>{$fields['title']}</div>"; | |
echo "</div>"; | |
echo "</a>"; | |
echo "</div>"; | |
echo "<div class='col-sm-3 directory-contact-wrap'>"; | |
echo "<div class='directory-phone'>{$fields['phone']}</div>"; | |
echo "<div class='directory-email'><a href=mailto:{$emailAddress}>{$emailAddress}</a></div>"; | |
echo "</div>"; | |
echo "<div class='col-sm-4 directory-office-wrap'>"; | |
echo "<div class='directory-officeLabel'>Office</div>"; | |
echo "<div class='directory-office'>{$fields['office_location']}</div>"; | |
echo "</div>"; | |
echo "</div>"; // top level row | |
echo "</div>"; // directory-person | |
$output = ob_get_clean(); | |
echo $output; | |
} | |
echo "</div>"; | |
?> | |
</div> | |
<?php include get_template_directory().'/inc/sidebar-if-active.php';?> | |
</div> | |
<?php include get_template_directory().'/inc/submenu-closing-tags.php';?> | |
<?php endwhile; // end of the loop. ?> | |
</div> | |
<?php get_footer(); ?> |