Adding related listings to listing detail page

From JReviews Documentation
Revision as of 15:19, 15 February 2010 by Alejandro (Talk | contribs) (Customizations)

Jump to: navigation, search

You can add a Related listings "module" to your listing detail page to display related listings based on a common custom field. This is a hack of the Listings Module.


The code you need to enter in detail.thtml file to display related listings is:

<?php echo $this->element('related_listings',array('field'=>'jr_name','suffix'=>''));?>

Replace jr_name with the name of your custom field.


Example:

For a hotel/restaurant listings, you can use jr_city custom field to display related listings based on City:

<h2>Related Listings</h2>
<?php echo $this->element('related_listings',array('field'=>'jr_city','suffix'=>''));?>

When viewing a certain New York listing, the above code will display the related New York listings:

RelatedListings.png


Customizations

To see the different settings that can be passed in the related listings call, view this file:

  • \com_jreviews\jreviews\views\themes\default\elements\related_listings.thtml

Since Related listings module is an extension of the Listings module, it uses the same theme file:

  • \com_jreviews\jreviews\views\themes\default\modules\listings.thtml


Modifying the related listings theme file

To modify the theme for related listings output only, create a copy and add a suffix to the file, for example: listings_related.thtml

To use that theme add '_related' suffix into the code:

<?php echo $this->element('related_listings',array('field'=>'jr_name','suffix'=>'_related'));?>

Passing additional settings to the related listings call

Additional settings can be passed in 2nd parameter array of the $this->element class method.

Limiting results to a single category

<?php echo $this->element('related_listings',array('field'=>'jr_name','category'=>'10'));?>

Limiting results to several categories

<?php echo $this->element('related_listings',array('field'=>'jr_name','category'=>'10,11,12'));?>

Changing the size of the thumbnail

<?php echo $this->element('related_listings',array('field'=>'jr_name','tn_width'=>'200'));?>

Enabling ajax pagination

<?php echo $this->element('related_listings',array('field'=>'jr_name','ajax'=>1));?>

Changing the number of listings and columns

<?php echo $this->element('related_listings',array('field'=>'jr_name','module_limit'=>9,'columns'=>3));?>