Difference between revisions of "Adding related listings to listing detail page"
(Created page with '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 c…') |
|||
(17 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | <div class="successbox" style="width: 95%"> | ||
+ | |||
+ | [https://www.jreviews.com/docs/theme-resources/embedding-related-listings There's a new version of this article] | ||
+ | |||
+ | </div> | ||
+ | |||
+ | |||
+ | Make sure you also read the article on [[Listing Detail Page Widgets]]. | ||
+ | The easiest way to describe what you can do with related listings is to use some examples. Let's say you have a movie directory where you have both actor and movie listings. With related listings you can show movies for each actor's listing. The same can be applied to manufacturers and products, venues and events, etc. You will need to have a common custom field that exists in both types of listings to make the association. In the actor's example, you would need to include the actor field in both the actor listing and the movie listing. | ||
+ | |||
+ | For even more options on embedding the listing module in detail pages read the article [[Adding custom JReviews modules into listing detail pages]] | ||
+ | |||
+ | __TOC__ | ||
+ | |||
+ | ==Basic usage== | ||
+ | |||
You can add a Related listings "module" to your listing detail page to display related listings based on a common custom field. | 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]]. | This is a hack of the [[Listings Module]]. | ||
− | |||
The code you need to enter in detail.thtml file to display related listings is: | The code you need to enter in detail.thtml file to display related listings is: | ||
Line 27: | Line 42: | ||
== Customizations == | == Customizations == | ||
− | To | + | To see the different settings that can be passed in the related listings call, view this file: |
*<span style="color: blue">\com_jreviews\jreviews\views\themes\default\elements\related_listings.thtml</span> | *<span style="color: blue">\com_jreviews\jreviews\views\themes\default\elements\related_listings.thtml</span> | ||
− | + | Since Related listings module is an extension of the Listings module, it uses the same theme file: | |
− | Since Related listings module is | + | |
*<span style="color: blue">\com_jreviews\jreviews\views\themes\default\modules\listings.thtml</span> | *<span style="color: blue">\com_jreviews\jreviews\views\themes\default\modules\listings.thtml</span> | ||
− | + | ===Modifying the related listings theme file=== | |
− | To use that | + | To modify the theme for related listings output only, create a copy and add a suffix to the file, for example: <span style="color: blue">listings_related.thtml</span> |
+ | |||
+ | To use that theme add '_related' suffix into the code: | ||
<source lang="php"> | <source lang="php"> | ||
<?php echo $this->element('related_listings',array('field'=>'jr_name','suffix'=>'_related'));?> | <?php echo $this->element('related_listings',array('field'=>'jr_name','suffix'=>'_related'));?> | ||
+ | </source> | ||
+ | |||
+ | [[Category:JReviews]] | ||
+ | [[Category:Themes]] | ||
+ | [[Category:Listing Detail Page]] | ||
+ | |||
+ | ===Passing additional settings to the related listings call=== | ||
+ | |||
+ | Additional settings can be passed in 2nd settings array of the $this->element class method. You can combine any of the settings shown below by adding them to the array separated by comma. | ||
+ | |||
+ | ====Limiting results to a single category==== | ||
+ | |||
+ | <source lang="php"> | ||
+ | <?php echo $this->element('related_listings',array('field'=>'jr_name','cat_id'=>'10'));?> | ||
+ | </source> | ||
+ | |||
+ | ====Limiting results to several categories==== | ||
+ | |||
+ | <source lang="php"> | ||
+ | <?php echo $this->element('related_listings',array('field'=>'jr_name','cat_id'=>'10,11,12'));?> | ||
+ | </source> | ||
+ | |||
+ | ====Changing the number of listings and columns==== | ||
+ | |||
+ | <source lang="php"> | ||
+ | <?php echo $this->element('related_listings',array('field'=>'jr_name','limit'=>6,'total'=>24,'cols'=>3));?> | ||
+ | </source> | ||
+ | |||
+ | ====Enabling category auto-detect==== | ||
+ | |||
+ | <source lang="php"> | ||
+ | <?php echo $this->element('related_listings',array('field'=>'jr_name','cat_auto'=>true,'limit'=>2,'cols'=>2));?> | ||
</source> | </source> |
Latest revision as of 00:03, 9 July 2020
Make sure you also read the article on Listing Detail Page Widgets.
The easiest way to describe what you can do with related listings is to use some examples. Let's say you have a movie directory where you have both actor and movie listings. With related listings you can show movies for each actor's listing. The same can be applied to manufacturers and products, venues and events, etc. You will need to have a common custom field that exists in both types of listings to make the association. In the actor's example, you would need to include the actor field in both the actor listing and the movie listing.
For even more options on embedding the listing module in detail pages read the article Adding custom JReviews modules into listing detail pages
Contents
Basic usage
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:
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
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'));?>
Additional settings can be passed in 2nd settings array of the $this->element class method. You can combine any of the settings shown below by adding them to the array separated by comma.
Limiting results to a single category
<?php echo $this->element('related_listings',array('field'=>'jr_name','cat_id'=>'10'));?>
Limiting results to several categories
<?php echo $this->element('related_listings',array('field'=>'jr_name','cat_id'=>'10,11,12'));?>
Changing the number of listings and columns
<?php echo $this->element('related_listings',array('field'=>'jr_name','limit'=>6,'total'=>24,'cols'=>3));?>
Enabling category auto-detect
<?php echo $this->element('related_listings',array('field'=>'jr_name','cat_auto'=>true,'limit'=>2,'cols'=>2));?>