OfficeRoster Widget with SDK for PHP

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:

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]" } };
    function mbbMapLoaded(){ MBB.googleMaps = true; };
    </script>
    <script src='https://maps.googleapis.com/maps/api/js?callback=mbbMapLoaded&libraries=places&key=[YOUR_GOOGLE_MAPS_API_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 locations
  • office:off - Hides office locations
  • mapPin:blue - Sets map pin color
  • search:on - Enables search functionality
  • layout:grid - Uses grid layout
  • layout:list - Uses list layout

URL Slug Examples

The widget recognizes these slug patterns:

  • index - Office locations map
  • roster - Agent roster list
  • roster/last/c - Agents with last name starting with 'C'
  • roster/search/keyword - Search results
  • roster/id/7 - Specific office agents
  • agent/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-smith instead 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:

  1. Check .htaccess rules: Ensure URL rewriting is configured correctly
  2. Verify PHP parsing: Make sure your server processes the team page correctly
  3. 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

  1. Test Default View: Access /team to see the default office view
  2. Test Office Roster: Access /team/office to see the agent roster
  3. Test Agent Profiles: Access /team/agent-name to see individual profiles
  4. Check URL Structure: Verify all links work correctly
  5. 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

Note: OfficeRoster widget with SDK requires custom implementation. Contact support if you need assistance with this advanced feature.

Updated on July 7, 2025
Was this article helpful?

Related Articles

Need Support?
Can't find the answer you're looking for?
Contact Support
Buying Buddy Support