Staff List With Filter and Simple Styling - TheFrozenFire/PHP-Mindbody-API-Library GitHub Wiki
require("services/Staff_Service.php");//use your own path to Staff_Service.php
$service = new Staff_Service();
//set the parameters for the soap request
$parameters = new GetStaff();
$parameters->Request = new GetStaffRequest();
$parameters->Request->SourceCredentials = new SourceCredentials();
$parameters->Request->SourceCredentials->SourceName; //set this in structures/SourceCredentials.php
$parameters->Request->SourceCredentials->Password; //set this in structures/SourceCredentials.php
$parameters->Request->SourceCredentials->SiteIDs; //set this in structures/SourceCredentials.php
/*apply available filters based on your needs. You can find the filters that you
can use in the structures/StaffFilter.php
*/
$parameters->Request->Filters = array('AppointmentInstructor');
//create the staff object
$object = $service->GetStaff($parameters);
//pull out just staff members arrays from the object and store them all in $staff variable
$staff = $object->GetStaffResult->StaffMembers->Staff;
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Meet the therapists</title>
<style>
/*Very simple styling to show what is possible. Make your own the way you want it! */
p,div, h1,h2,h3,h4,h5,h6{
margin:0;
padding:0;
}
body{
background: #fff;
}
h2{color: #333; margin-bottom: 20px;}
.container{
font-family: sans-serif;
width: 800px;
margin: auto;
padding-top: 35px;
}
.employee{
margin-bottom: 20px;
background: #E2E2E2;
overflow: hidden;
padding: 0 0 15px 0;
display: block;
height: auto;
}
.name{
margin-bottom: 20px;
background: #F3F3F3;
padding: 5px 15px;
}
.name h3{
font-size: 20px;
color: #333;
text-shadow: 0 1px 0 #fff;
}
.image{
float: left;
padding-left: 15px;
}
.image img{
margin: 0 20px 0 0;
border: 1px solid black;
}
.bio{
float: right;
padding-right: 15px;
width: 615px;
font-size: 16px;
color: #333;
text-align: justify;
}
.clear{
clear: both;
}
</style>
</head>
<body>
<div class="container">
<h2>Meet The Staff</h2>
<?php
//iterate through staff members individually
foreach( $staff as $emp )
{
/*put stuff in variables so the html is cleaner looking and we can perform logic on it
here instead of in our html
*/
$id = $emp->ID;//get the ID for each employee for id filtering in if statement below
$name = $emp->Name;
$img = $emp->ImageURL;
$bio = strip_tags($emp->Bio);//remove div tags from returned bio.
//replace image with placeholder image if it does not exist in the sytem
if($img == null){
$img = "http://placehold.it/133x201";
}
//replace bio with default text if it does not exist in the system.
if(strlen($bio) < 4){
$bio = "Bio coming soon!";
}
//remove staff based on $id variable.
if($id != 10000000 /* || */ /* $id != {{enter your specific ID here}}*/){
?>
<div class="employee">
<div class="name">
<h3><?php echo $name; ?></h3>
</div>
<div class="image">
<img src="<?php echo $img; ?>"/>
</div>
<div class="bio">
<p><?php echo $bio; ?></p>
</div>
</div>
<div class="clear"></div>
<?php
}//end if
} //END FOREACH
?>
</div><!--end container-->
</body>
</html>
⚠️ **GitHub.com Fallback** ⚠️