SEO with Widgets in PHP

This article provides a simple introduction to the MBB API. Full documentation of the API is being developed and will be made available shortly.

Overview

If you have a PHP website, then this API can work in conjunction with the MBB JavaScript plugin, enabling the additional following SEO features:

  • Indexable Listings: The display widgets (List Widget, Gallery Widget - but not results widget) will output HTML code that includes links to listings that can be followed by Search Engines
  • Long Tail URLs: The structure of the property details page will NOT include a question mark
  • Details Page Optimization: The Title and Meta Description tags on property details pages will be written to include the property address

1 The use of this API is purely optional. It is ONLY required if you wish to extend the function of the MBB JavaScript plugin to also provide SEO benefits.

2 To use this feature you will need an API Key, which is available in your Account Settings.

Note:
This API is not supported for use on a WordPress Website. It may be technically possible to use the API rather than the MBB WordPress Plugin, but currently this is not supported.

Once installed, the API executes and presets values before the HTML is output for a page in the browser.
This method therefore allows you to access and use property-specific PHP variables to set SEO options on a property details page such as Meta Tags, OG Tags and so on.

Checklist

To utilize these capabilities on your PHP site, the following items are required:

  1. Your MBB account ID (ACID) = {your_mbb_account_id}
  2. Your google Map API key = {your_google_map_api_key}
  3. API ZIP file: Download and load the assets in a www/mbb folder

Implementation

  1. Include the PHP API in the top of pages
  2. Modify the <script> tags that you have used to load the MBB JavaScript on all your web pages.
    See below for the Alternative JavaScript code to use.
  3. Set variables for SEO using the various PHP objects
  4. Ensure the "Indexable Listings" feature is enabled on your account in your Account Settings.
    See below for how to check this.
  5. Make sure that you have set the 'search results' and 'property details' pages to be PHP pages
    See "Website Configuration" in your LAC account.

Call the API

<?
require_once "mbb/MyBuyingBuddy.php";
$mbbObj = new MyBuyingBuddy( array("acid" => "{your_mbb_account_id}") );
$loginObj = $mbbObj->getWidget("MBBv3_LoginPanel", array("filter" => "layout:horizontal") );
$propertyObj = $mbbObj->getWidget("MBBv3_SearchDetails", array("property_id" => $mbbObj->getPropertyIdFromURL() ) );
?>

Alternative MBB JavaScript

Use the following updated MBB JavaScript code. If you are updating your website then make sure you remove the original JavaScript.

This JavaScript MUST BE LOADED IN THE <head> of all pages.

What You need:

  1. API ZIP
  2. Your website domain that matches what is shown in the Widgets / Configuration panel = {your_website_domain}
<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?key={your_google_map_api_key}'></script>
<script type='text/javascript'>
var MBB = { mbbUrl: 'https://www.mbb2.com/version3', seo : 'true' };
MBB.data = { acid : "{your_MBB_account_ID}", mbbdomain : "{your_website_domain}"};
</script>
<script type='text/javascript' src='https://www.mbb2.com/scripts/my-buying-buddy.4.0.js'></script>

Using MBB Objects

For SEO benefits, you can set the values of various META tags using PHP objects.

<meta name="keywords" content="<?=$propertyObj->meta_keywords?>" />
<meta name="description" content="<?=$propertyObj->meta_description?>" />

BODY

<h1><?=$propertyObj->h1?></h1>
<div id="MBBv3_SearchDetails"><?=$propertyObj->html?></div>

Examples

Property Details Example

<?
require_once "mbb/MyBuyingBuddy.php"; /* calls the PHP api */
$mbbObj = new MyBuyingBuddy( array("acid" => "{your_mbb_account_id}") ); /* sets up the ACID for the PHP environment */
$loginObj = $mbbObj->getWidget("MBBv3_LoginPanel", array("filter" => "layout:horizontal") );
$propertyObj = $mbbObj->getWidget("MBBv3_SearchDetails", array("property_id" => $mbbObj->getPropertyIdFromURL() ) );
?>

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="description" content="<?=$propertyObj->meta_description?>" />
<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?key={Your_Google_map_api_key}'></script>
<script type='text/javascript' src='https://www.mbb2.com/version3/css/theme/acid/{your_mbb_account_id}?ver=4.1'></script>
<script type='text/javascript'>
var MBB = { mbbUrl: 'https://www.mbb2.com/version3', seo : 'true' };
MBB.data = {acid : "{your_mbb_account_id}", mbbdomain : "{your_website_domain}"};
</script>
<script type='text/javascript' src='https://www.mbb2.com/scripts/my-buying-buddy.4.0.js'></script>
<?=$propertyObj->og_tags?>
</head>
<body>
<h1><?=$propertyObj->h1?></h1>
<div id="MBBv3_SearchDetails"><?=$propertyObj->html?></div>
</body>
</html>

HTACCESS Example

This is an example of HTACCESS for setting up a single property details PHP page for all property details

RewriteEngine on
RewriteRule ^property.*$ property.php [L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

Updated on February 26, 2022

Was this article helpful?

Related Articles

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