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?
cornerstone/inc/people-table.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
159 lines (133 sloc)
4.48 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 | |
$the_query = new WP_Query( $args ); | |
if ( $the_query->have_posts() ) { | |
// how many columns? Based on what they chose to display. | |
$num_cols = count($information_to_display); | |
//var_dump($num_cols); | |
?> | |
<div class="table-responsive"> | |
<table class="table table-striped"> | |
<legend class="sr-only">List of People</legend> | |
<thead> | |
<tr> | |
<?php | |
$nameCell = false; | |
foreach($information_to_display as $value){ | |
if ($value == 'first_name' || $value == 'middle_name' || $value == 'last_name'){ | |
if ($nameCell == false){ | |
echo '<th>Name</th>'; | |
$nameCell = true; | |
}; | |
} elseif ($value == 'photo') { | |
echo '<th> </th>'; | |
} else { | |
//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); | |
while ( $the_query->have_posts() ) { | |
$the_query->the_post(); | |
/* | |
create a row. | |
For each possible field. | |
Check to see if it's within the $information_to_display array. | |
If it is, create a <td> | |
IF any values are found to match, dump those out. | |
After all possible fields, close the row. | |
*/ | |
echo '<tr>'; | |
if (in_array('photo', $information_to_display)) { | |
echo '<td class="person-image"><a href="'.get_the_permalink().'">'; | |
the_post_thumbnail(array('65', '65')); | |
echo '</a></td>'; | |
} | |
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">'; | |
$external_url = get_field('external_url'); | |
if ( $external_url != "" ){ | |
echo '<a href="'.$external_url.'" target="_blank">'; | |
}else{ | |
echo '<a href="'.get_the_permalink().'">'; | |
} | |
if (in_array('first_name', $information_to_display)) { | |
the_field('first_name'); | |
echo ' '; | |
}; | |
if (in_array('middle_name', $information_to_display)) { | |
the_field('middle_name'); | |
echo ' '; | |
}; | |
if (in_array('last_name', $information_to_display)) { | |
the_field('last_name'); | |
}; | |
echo '</a></td>'; | |
} | |
//createTextCell('title', 'title'); | |
if (in_array('title', $information_to_display)) { | |
echo '<td class="person-title">'; | |
$titlePieces = explode(";", get_field('title')); | |
foreach( $titlePieces as $t ){ | |
echo ( !empty($t) ? "<strong>{$t}</strong><br>": "" ); | |
} | |
echo '</td>'; | |
} | |
if (in_array('department', $information_to_display)) { | |
echo '<td class="person-department">'; | |
$departmentPieces = explode(";", get_field('department')); | |
foreach( $departmentPieces as $d ){ | |
echo ( !empty($d) ? "<strong>{$d}</strong><br>": "" ); | |
} | |
echo '</td>'; | |
} | |
createTextCell('about', 'about'); | |
if (in_array('file', $information_to_display)) { | |
echo '<td class="person-file">'; | |
$file = get_field('file'); | |
echo '<a href="'.$file[url].'">'.$file[title].'</a>'; | |
echo '</td>'; | |
}; | |
if (in_array('email', $information_to_display)) { | |
echo '<td class="person-email">'; | |
echo '<a href="mailto:'.get_field('email').'">'.get_field('email').'</a>'; | |
echo '</td>'; | |
}; | |
// If the phone number ('phone') is part of the information being displayed than we should replace any hyphens with the html entity for a non-break hyphen (‑) | |
if (in_array('phone', $information_to_display)) { | |
$phoneStrReplace = str_replace('-', '‑', get_field('phone')); | |
echo '<td>'.$phoneStrReplace.'</td>'; | |
} | |
//createTextCell('phone', 'phone'); | |
createTextCell('phone_(alternate)', 'phone_(alternate)'); | |
createTextCell('fax', 'fax'); | |
//createTextCell('mailing_address', 'mailing_address'); | |
if (in_array('mailing_address', $information_to_display)) { | |
echo '<td class="person-mailing_address">'; | |
echo str_replace(';','<br>',get_field('mailing_address')); | |
echo '</td>'; | |
} | |
createTextCell('office_location', 'office_location'); | |
createTextCell('campus', 'campus'); | |
createTextCell('office_hours', 'office_hours'); | |
createTextCell('courses', 'courses'); | |
if (in_array('url', $information_to_display)) { | |
echo '<td class="person-url">'; | |
echo '<a href="'.get_field('url').'">'.get_field('url').'</a>'; | |
echo '</td>'; | |
}; | |
echo '</tr>'; | |
} //end of posts?> | |
</tbody> | |
</table> | |
</div> | |
<?php | |
} else { | |
// no posts found | |
}; ?> |