1. Home
  2. Widgets & Customization
  3. Widget Reference
  4. SDK for PHP - OfficeRoster Widget
  1. Home
  2. Widgets & Customization
  3. Advanced Techniques
  4. SDK for PHP - OfficeRoster Widget
  1. Home
  2. Installing Buying Buddy
  3. PHP SDK
  4. SDK for PHP - OfficeRoster Widget

SDK for PHP - OfficeRoster Widget

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/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 /team on the office locations map instead of the agent roster
  • mappin:blue - Sets the office map pin color: blue, gray, purple (default) or red
  • mappincur:red - Sets the pin color for the selected office (default gray)
  • searchbar:false - Hides the agent search bar, which is shown by default
  • sort:first - Sorts the roster by first name (last is the default; random and office also 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 includes office:on, otherwise the agent roster (an account with a single agent goes straight to that agent's profile)
  • 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/JohnSmith - Individual agent profile

SEO Benefits

When implemented with the SDK, the OfficeRoster widget provides:

Agent Profile Pages

  • SEO-friendly URLs: /team/JohnSmith instead 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:

  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, 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

  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/JohnSmith (the agent's first and last name run together) 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

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

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

Updated on November 30, 2026
Was this article helpful?

Related Articles

Buying Buddy Support