Show Staff List
// Add Shortcode
function show_staff_list( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'school' => '',
),
$atts
);
$staffFile = file("D:\web\phxschools.org\". $atts['school'] ."\staff.txt");
$needsTableEnd = 0;
$position = 0;
foreach ($staffFile as $lineNum => $line) {
if ($lineNum != 0) {
$lineArray = explode("t", $line);
if ($lineArray[1] == "" AND $lineArray[2] == "") {
if ($lineArray[0] != "") {
if ($needsTableEnd == 1) {
echo "</tbody></table></div>";
$needsTableEnd = 1;
}
echo "<div><span class='staffhead'>$lineArray[0]</span></div><div class='staffdiv'><table class='staff'>";
$needsTableEnd = 1;
$position = 0;
}
} else {
if ($position == 0) {
echo "<thead><tr><th>Position</th><th>Name</th><th>Room</th><th>Phone</th></tr></thead><tbody>";
}
echo "<tr><td>$lineArray[1]</td><td>$lineArray[0]</td><td>$lineArray[4]</td><td>$lineArray[2]</td></tr>";
$position = $position + 1;
}
}
}
if ($needsTableEnd == 1) {
echo "</tbody></table></div>";
}
}
add_shortcode( 'show-staff-list', 'show_staff_list' );