SEO with Widgets in PHP

This article provides a simple introduction to the Buying Buddy PHP Class and its use for SEO.

Overview

If you have a PHP website, then thr PHP Class can work in conjunction with the Buying Buddy 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

For more complete instructions on using the PHP class see Buying Buddy PHP Class and API.

1 The use of this API is purely optional. It is ONLY required if you wish to extend the function of the Buying Buddy 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 Buying Buddy 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 Account Activation Key = {Activation_Key}
  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 Buying Buddy JavaScript plugin 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 Buying Buddy account.

Call the API

<?php
    require_once "mbb/MyBuyingBuddy.php";
    $mbbObj = new MyBuyingBuddy( array("acid" => "{Activation_Key}") );
    $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 Buying Buddy JavaScript plugin code. If you are updating your website then make sure you remove the original Plugin 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: "{Activation_Key}",
        mbbdomain: "{your_website_domain}"
    };
</script>
<script type='text/javascript' src='https://www.mbb2.com/scripts/my-buying-buddy.4.0.js'></script>

Using Buying Buddy 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

<?php
/* calls the PHP api */
require_once "mbb/MyBuyingBuddy.php";
/* applies Activation Key for the PHP environment */
$mbbObj = new MyBuyingBuddy(["acid" => "{Activation_Key}"]);
$loginObj = $mbbObj->getWidget("MBBv3_LoginPanel", ["filter" => "layout:horizontal"]);
$propertyObj = $mbbObj->getWidget("MBBv3_SearchDetails", ["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 December 30, 2023

Was this article helpful?

Related Articles

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