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/john-smith) - 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/john-smith
}
// 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
If you need more specific routing:
# REDIRECT FOR AGENT PERSONAL PAGE
RewriteCond %{REQUEST_URI} !/team/ [NC]
RewriteCond %{REQUEST_URI} !/team/office/ [NC]
RewriteRule ^team/(.*)?$ /team/$1 [R=301,NC,L]
# REDIRECT FOR ALL OTHER OFFICE LINKS
RewriteCond %{REQUEST_URI} !/team/office/ [NC]
RewriteRule ^team/office/(.*)?$ /team$1 [R=301,NC,L]
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- Shows office locationsoffice:off- Hides office locationsmapPin:blue- Sets map pin colorsearch:on- Enables search functionalitylayout:grid- Uses grid layoutlayout:list- Uses list layout
URL Slug Examples
The widget recognizes these slug patterns:
index- Office locations maproster- Agent roster listroster/last/c- Agents with last name starting with 'C'roster/search/keyword- Search resultsroster/id/7- Specific office agentsagent/name/john-smith- Individual agent profile
SEO Benefits
When implemented with the SDK, the OfficeRoster widget provides:
Agent Profile Pages
- SEO-friendly URLs:
/team/john-smithinstead of query parameters - Indexable content: Agent information available to search engines
- Meta tag optimization: Automatic title and description generation
- Social sharing: Open Graph tags for agent profiles
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, you may need additional .htaccess rules:
# Prevent infinite loops
RewriteCond %{REQUEST_URI} !/team/ [NC]
RewriteCond %{REQUEST_URI} !/team/office/ [NC]
RewriteRule ^team/(.*)?$ /team/$1 [R=301,NC,L]
# Office link redirects
RewriteCond %{REQUEST_URI} !/team/office/ [NC]
RewriteRule ^team/office/(.*)?$ /team$1 [R=301,NC,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/agent-nameto 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
Add additional filtering based on URL parameters:
// Example: /team/office/denver
if (strpos($str, "office") !== false) {
$parts = explode("/", $str);
if (count($parts) > 2) {
$city = $parts[2];
$slug = "roster/city/" . $city;
} 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.