Related Listings
Showing related listings in detail pages is a great way to let your site visitors navigate connected listings and discover relevant content.
Overview
Related listings can be shown in listing detail pages through widgets, that can be setup directly in each listing type.
In addition to the related listing widgets, you can also show listings through shortcodes and template customizations.
Some of the relation types require the use of a related listing
custom field. This field type can also be used standalone, without the need for widgets.
Related Listing Custom Field
By using a related listing custom field, you allow users posting listings on your site to create direct, and indirect, relations for those listings.
When a listing is created or updated, it's possible to lookup existing listings within the custom field and select them. When the listing is saved, the selected listing titles will appear in the custom field output and link back to the listing. You can see an example on the demo site where Venue is a related listing custom field in Events, and it links back to the Venue listing.
When creating a related listing custom field, you can adjust the settings to:
- Filter suggestions by listing type
- Filter suggestions by category
- Filter suggestions to listings owned by the logged in user
- Change the sorting order for suggestions
- Limit the number of options that can be selected
Detail Page Widgets
There are many types of relations, some requiring a bit more setup than others.
When you create or update a listing type you'll find a Detail Page Widgets
tab where you can create up to 10 related listing widgets for a single listing.
There are many possible setups with lots of different permutations, so we'll cover the basics to help you get started.
This is the list of the related listing options available via related listing widgets:
- Same Category
- Same Field Value
- Same Listing Owner
- Related Listing Field - Direct
- Related Listing Field - Indirect
Same Category
Find Listings Where The category is the same as the current listing category
This is a simple mode that looks up listings solely based on category so you can display other listings that have the same category as the current listing.
Same Field Value
Find Listings Where The specified field matches the current listing field of the same name
In addition to selecting the Find Listing Where
option above, you need to fill the Field Name
value (e.g. jr_city, jr_brand).
This type of relation will look up other listings that have the same value selected, or filled in, for a given custom field.
A few ideas for when to use this type of relation:
- Movie listings to show other movies with the same actors
- Real estate listings to show other listings in the same city or postal code
- Business listings offering the same services
- Restaurants offering the same type of cuisine
Same Listing Owner
Find Listings Where The listing owner matches the current listing owner
This is one of the easiest relations to set up because the relation is automatically established based on listing ownership.
This type of relationship can be useful in many cases. Here's a few ideas:
- News articles and blog posts - to show other listings from the same author
- Store and business listings - to show offers and classified ads posted by the store/business owner. And vice-versa, it's possible to show the store/business information for each offer or ad.
- Real estate listings - to show properties in the realtor's listing, and the realtor information for each property.
- With the UserProfiles Add-on, display content posted by users in their listing profile page.
Related Listing Field (Direct)
Find Listings Where The specified field matches current listing id (Related Listing Field)
This type of relation requires a related listings
custom field to be available in the same listing type. You need to fill out the name of the field in the Field Name
setting.
So how does this all work?
When creating or updating listings the related listing
custom field is used to look up existing listings on the site and select one, or more, listings, depending on how you set up the field.
After saving, when visiting the listing, the default output of the related listing
custom field are links to the related listings. This can be hidden by toggling the detail view for the field.
In addition to the standard field output, you will also see the output of the related listings widget that you are setting up here. You can modify the widget output through the widget settings:
- Change the layout
- Add a comma list of custom fields to show
- Limit the number of results
- etc.
This related listing option can be useful for:
- Connecting event listings with a specific venue
- Connecting real estate listings with realtor listings, when they are not submitted by the same user. In that case you can also use the Same Listing Owner relation.
- Connecting actor listings with movie listings
- Connecting location-based listings with country, region or city listings. For example a resort that links to a city page that offers more information about that city.
You can create any type of connection needed between listings in order to show other listings within a listing.
Related Listing Field (Indirect)
Find Listings Where The listing id matches the value of the specified field (About Related Listing)
This type of relation requires having a related listing
custom field available either in the same listing type, or a different listing type. You need to fill out the name of the field in the Field Name
setting.
So how does this all work?
With Related Listing Field (Direct) relations, you specifically select the target
listings that you want to connect with the source
, or current listing.
This is a direct relationship.
When a direct relationship is created using a related listing
custom field, an indirect relationship becomes available. This indirect relationship goes from the target
listing, back to source
listing.
This can be more easily explained with an example. Our setup includes Venues and Events, and for Events we've created a related listing
custom field where we can select the Venue.
- When creating Events, we can select the Venue (which is also a listing) where the Event will take place.
- Having selected the Venue for the Event, now the Venue itself is automatically connected to the event via an indirect relationship.
- The only way to visualize this indirect relationship is by using the Related Listing Field (Indirect Relation) widget type - which is the topic of this section.
Each time you select a Venue for an Event, that Venue gains a new indirect relation. The widget allows showing all events taking place in a venue, within the venue page, even when the relation is created in the event.
Proximity Filter
If you use the MapsPro Add-on or the GeoMaps Add-on, you can automatically filter listings shown in the related listing widgets to listings that are in proximity to the current listing.
This feature works for all the related listing options and can be enabled by changing the Listing Ordering
setting to Proximity
.
You can also adjust the radius that you want to use for proximity filtering.
Synchronous vs. Asynchronous Loading
By default the widgets load asynchronously. This means that a separate request is made for each widget to load the data, only after the page finishes loading. This is good when it comes to page loading speeds, because less database queries and code need to be processed during the intial page load. It also allows you to show the widgets anywhere on the page as explained in the next section.
If you want to be sure that the related listings info is seen as being a part of the listing for SEO-puposes, you may want to disable the asynchronous feature for some of your widgets. You can do that by toggling off the Load Asynchronously
setting.
It all comes down to performance vs indexability and when it comes to Google, testing is the only way to find out what works best for SEO.
Custom Placement
When a widget is set to load asynchrously, you also have the option of showing the widget output anywhere on the page instead of the default placement.
There are two settings that allow you to control the placement:
- Target Element ID
- Target Element Class
These refer to the HTML attributes of an element.
<div id="some-id" class="some-class"></div>
You need to use one, or the other, not both. By default all widgets use the Target Element ID
which is set to jrRelatedListings
. Because the listing detail template already has a div element with that ID attribute, all widget are placed there.
Some ideas for placing widgets in custom locations on the listing detail page:
- Load a widget in a sidebar using a Joomla HTML Module or WordPress HTML widget to create an empty div with a custom id or class attribute that matches the value you add to the above settings
- Load a widget within a banner custom fields where you add the empty div inside the banner description
- Load a widget anywhere in the listing detail template by adding the empty div to the template itself.
Widget Template Customization
The listing widgets use the same template as the JReviews listings Joomla module and WordPress widget, so you can customize their template as explained in template overrides.
The same is true for using theme suffixes for which there is a setting in each widget.
For example, if you use a _hotels
suffix, you would place the template override in your custom theme in the following structure:
`-- mysite/
|-- themeInfo.xml
`-- modules/
`-- listings_hotels.thtml
Advanced Filters
If you need more advanced options to control the results of a related listing widget, you can also use the Custom Where
and Custom Order
settings. You can learn more about using these settings in Custom Lists.