This guide explains how to implement the OfficeRoster widget with the Buying Buddy SDK for PHP to create SEO-friendly agent profile pages with permalinks.
Prerequisites
Before implementing the OfficeRoster widget with SDK:
- Complete SDK Overview & Setup
- Review the OfficeRoster widget documentation for widget basics
- Ensure you're using the latest Buying Buddy JavaScript plugin
- Have PHP environment with URL rewriting capabilities
Overview
The OfficeRoster widget with SDK for PHP enables:
- SEO-friendly agent profile URLs (e.g.,
/team/JohnSmith) - Indexable agent profiles with proper meta tags
- Office directory pages with search engine optimization
- Custom URL structures for better user experience
URL Structure
The SDK creates these URL patterns automatically:
/team- Shows office locations or roster (configurable)/team/office- Shows the roster of users/agents/team/ProfileName- Shows individual agent profile
Important: These URLs are built into the widget links and must be followed exactly for proper functionality.
Implementation Steps
Step 1: Create Team Page
Create a page accessible at /team that will handle all office roster functionality.
Step 2: Add SDK Code
Add this code to your /team page:
<?php
require_once "mbb/MyBuyingBuddy.php";
$mbbObj = new MyBuyingBuddy( array(
"api_key" => "[YOUR_API_KEY]",
"acid" => "[ACTIVATION_KEY]"
)
);
// Parse the URL to determine what to display
// Strip out "/team" to get remaining URI string
$str = str_replace("/team", "", $_SERVER['REQUEST_URI']);
// Remove trailing slash or file extensions if needed
$str = rtrim($str, '/');
$str = str_replace('.php', '', $str);
// Determine the slug based on URL structure
if (empty($str)) {
// Default view - show offices or roster
// Use "roster" instead of "index" to show agent roster by default
$slug = "index"; // Shows office locations map
// $slug = "roster"; // Uncomment to show agent roster instead
} else if (strpos($str, "office") !== false) {
// Office roster view
$slug = str_replace("/office", "roster", $str);
// Examples: roster, roster/last/c, roster/search/xxxx, roster/id/7
} else {
// Individual agent profile
$slug = "agent/name" . $str;
// Example: agent/name/JohnSmith
}
// Get the widget with the determined slug
$brokersObj = $mbbObj->getWidget("MBBv3_OfficeRoster", array("filter" => "office:on+mappin:blue"), $slug);
?>
Step 3: HTML Implementation
Add the HTML for the widget:
<div id="MBBv3_OfficeRoster" filter="office:on+mappin:blue">
<?php echo $brokersObj->html?>
</div>
Step 4: URL Rewriting Configuration
Apache .htaccess
Add these rewrite rules to your .htaccess file:
RewriteEngine On # Handle team pages RewriteRule ^team/?$ team.php [L] RewriteRule ^team/(.*)$ team.php [L]
For More Complex Routing
You do not need more rules than the two above: they send every /team URL to your team page, and the code in Step 2 works out what to show from the URL itself. On an nginx server, the equivalent is:
location ~ ^/team(/.*)?$ {
try_files $uri /team.php?$args;
}
Complete Implementation Example
Here's a complete example of a team page with the OfficeRoster widget:
<?php
require_once "mbb/MyBuyingBuddy.php";
$mbbObj = new MyBuyingBuddy( array(
"api_key" => "[YOUR_API_KEY]",
"acid" => "[ACTIVATION_KEY]"
)
);
// URL parsing and slug determination
$str = str_replace("/team", "", $_SERVER['REQUEST_URI']);
$str = rtrim($str, '/');
if (empty($str)) {
$slug = "index";
} else if (strpos($str, "office") !== false) {
$slug = str_replace("/office", "roster", $str);
} else {
$slug = "agent/name" . $str;
}
$brokersObj = $mbbObj->getWidget("MBBv3_OfficeRoster", array("filter" => "office:on+mappin:blue"), $slug);
?>
<!DOCTYPE html>
<html>
<head>
<title>Our Team</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- Buying Buddy plugin -->
<script src="https://www.mbb2.com/version3/css/theme/acid/[ACTIVATION_KEY]"></script>
<script>
var MBB = { seo : "true", data:{ acid : "[ACTIVATION_KEY]" } };
</script>
<script src="https://d2w6u17ngtanmy.cloudfront.net/scripts/my-buying-buddy.5.0.js.gz"></script>
<!-- End Buying Buddy plugin -->
</head>
<body>
<div id="MBBv3_OfficeRoster" filter="office:on+mappin:blue">
<?php echo $brokersObj->html?>
</div>
</body>
</html>
Widget Configuration Options
Filter Options
The OfficeRoster widget supports various filter options:
office:on- Opens/teamon the office locations map instead of the agent rostermappin:blue- Sets the office map pin color:blue,gray,purple(default) orredmappincur:red- Sets the pin color for the selected office (defaultgray)searchbar:false- Hides the agent search bar, which is shown by defaultsort:first- Sorts the roster by first name (lastis the default;randomandofficealso work)officeid:7- Shows only the agents in one office
URL Slug Examples
The widget recognizes these slug patterns:
index- Default view: the office locations map when the filter includesoffice:on, otherwise the agent roster (an account with a single agent goes straight to that agent's profile)roster- Agent roster listroster/last/c- Agents with last name starting with 'C'roster/search/keyword- Search resultsroster/id/7- Specific office agentsagent/name/JohnSmith- Individual agent profile
SEO Benefits
When implemented with the SDK, the OfficeRoster widget provides:
Agent Profile Pages
- SEO-friendly URLs:
/team/JohnSmithinstead of query parameters - Indexable content: Agent information available to search engines
Office Directory
- Structured data: Proper HTML structure for search engines
- Internal linking: SEO-friendly links between agent profiles
- Local SEO: Office location information with proper markup
Troubleshooting
Common Issues
404 Errors on Agent Profiles
If you see 404 errors when accessing agent profile pages:
- Check .htaccess rules: Ensure URL rewriting is configured correctly
- Verify PHP parsing: Make sure your server processes the team page correctly
- Test URL structure: Confirm the URL patterns match your implementation
Joomla-Specific Issues
For Joomla sites, place the two rules from Step 4 above Joomla's own rewrite rules in .htaccess, so /team requests reach your team page before Joomla's router handles them:
# Place these above Joomla's own rewrite rules RewriteRule ^team/?$ team.php [L] RewriteRule ^team/(.*)$ team.php [L]
Testing Your Implementation
- Test Default View: Access
/teamto see the default office view - Test Office Roster: Access
/team/officeto see the agent roster - Test Agent Profiles: Access
/team/JohnSmith(the agent's first and last name run together) to see individual profiles - Check URL Structure: Verify all links work correctly
- Validate HTML: Ensure proper HTML structure for SEO
Advanced Configuration
Custom Default View
To show the agent roster instead of office locations by default:
if (empty($str)) {
$slug = "roster"; // Shows agent roster instead of office map
}
Custom Filtering
Show one office's agents at a friendly URL by mapping it to the office ID (the number in that office's roster link, such as /team/office/id/7):
// Example: /team/office/denver shows the Denver office's agents
$offices = array("denver" => 7, "boulder" => 12); // your office IDs
if (strpos($str, "office") !== false) {
$parts = explode("/", $str);
if (count($parts) > 2 && isset($offices[$parts[2]])) {
$slug = "roster/id/" . $offices[$parts[2]];
} else {
$slug = str_replace("/office", "roster", $str);
}
}
Next Steps
- Review Widget Options: See the OfficeRoster widget documentation for all available features
- Customize Styling: Use Widget Themes or custom CSS to match your site design
- Implement Additional Widgets: Add other widgets using the Widget Implementation Reference
Note: OfficeRoster widget with SDK requires custom implementation. Contact support if you need assistance with this advanced feature.