Skip to content

Commit

Permalink
Use full address with city/state/zip in listing search results
Browse files Browse the repository at this point in the history
This updates the search results view to show the full address with
city, state, and zip code for each search result item.

Previously we were only showing the street address, without the city
and additional information. Adding this information should have some
good SEO benefits because: 1) there's more information to index, and
2) the link text to the listing details page matches the title of the
listing details page itself.

**NOTE** There are a few other spots (widgets, slider, etc) where we
still only show the street address and not the full address. I want to
make sure this change doesn't break too many people's styles/theme/etc
before changing it in too many spots.
  • Loading branch information
CodyReichert committed Jul 10, 2019
1 parent a5f9716 commit bb00c71
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
11 changes: 5 additions & 6 deletions simply-rets-api-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,6 @@ public static function srResidentialDetailsGenerator( $listing ) {
!empty($vendor) ? array("sr_vendor" => $vendor) : array()
);

$addrFull = $address . ', ' . $city . ' ' . $listing_postal_code;

/**
* Google Map for single listing
*/
Expand Down Expand Up @@ -1301,8 +1299,8 @@ public static function srResidentialResultsGenerator( $response, $settings ) {
* Listing status to show. This may return a statusText.
*/
$mls_status = SrListing::listingStatus($listing);
$full_address = SrUtils::buildFullAddressString($listing);

$addrFull = $address . ', ' . $city . ' ' . $zip;
$listing_USD = $listing_price == "" ? "" : '$' . number_format( $listing_price );

if( $bedrooms == null || $bedrooms == "" ) {
Expand Down Expand Up @@ -1349,7 +1347,7 @@ public static function srResidentialResultsGenerator( $response, $settings ) {
$iwCont = SrSearchMap::infoWindowMarkup(
$link,
$main_photo,
$address,
$full_address,
$listing_USD,
$bedrooms,
$bathsFull,
Expand Down Expand Up @@ -1423,8 +1421,9 @@ public static function srResidentialResultsGenerator( $response, $settings ) {
<div class="sr-listing-data-wrapper">
<div class="sr-primary-data">
<a href="$link">
<h4>$address
<span class="sr-price"><i>$listing_USD</i></span></h4>
<h4>$full_address
<small class="sr-price"><i> - $listing_USD</i></small>
</h4>
</a>
</div>
<div class="sr-secondary-data">
Expand Down
2 changes: 1 addition & 1 deletion simply-rets-maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static function infoWindowMarkup(

$markup = <<<HTML
<div class="sr-iw-inner">
<h4 class="sr-iw-addr">$address<small> $price</small></h4>
<h4 class="sr-iw-addr">$address<small> - $price</small></h4>
<div class="sr-iw-inner__img">
<a href='$link'>
<img id="sr-iw-inner__img-img" src='$photo'>
Expand Down
35 changes: 20 additions & 15 deletions simply-rets-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,25 @@ public static function normalizeCountyText($county) {
return $county_text;
}

/**
* Render a listings full address with state and postalCode
* <street address>, <city>, <state> <zip>
*/
public static function buildFullAddressString($listing) {

$city = $listing->address->city;
$state = $listing->address->state;
$zip = $listing->address->postalCode;
$address = $listing->address->full;

// A listing might have a null address if a flag like "Display
// address" is set to false. This just removes the comma in
// these cases, but the rest of the address remains the same.
$comma = $address ? ', ' : '';

return $address . $comma . $city . ', ' . $state . ' ' . $zip;
}

/**
* Builds a link to a listings' details page. Used in search results.
*/
Expand All @@ -122,25 +141,11 @@ public static function buildDetailsLink($listing, $params = array()) {

// Listing details
$listing_id = $listing->mlsId;

$listing_city = $listing->address->city;
$listing_state = $listing->address->state;
$listing_zip = $listing->address->postalCode;
$listing_address = $listing->address->full;

// A listing might not have a null address if a flag like
// "Display address" is set to false. This just removes the
// comma in these cases, but the rest of the address remains
// the same.
$comma = $listing_address ? ', ' : '';

$listing_address_full = $listing_address
. $comma
. $listing_city
. ', '
. $listing_state
. ' '
. $listing_zip;
$listing_address_full = SrUtils::buildFullAddressString($listing);

if($prettify && $custom_permalink_struct === "pretty_extra") {

Expand Down

0 comments on commit bb00c71

Please sign in to comment.