Skip to content

Commit

Permalink
Merge pull request #31 from rdowner22/bug/IMPB-1494-similar-im-press-…
Browse files Browse the repository at this point in the history
…carousel-widget-shows-duplicate-listing-when-there-are-not-enough-listings

IMPB-1494: Use an ID for owl carousel to prevent single listings to b…
  • Loading branch information
rdowner22 authored Jun 7, 2024
2 parents d97f550 + 0339eb4 commit 1863707
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions idx/shortcodes/register-impress-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,9 @@ public function property_carousel_shortcode( $atts = array() ) {

$count = 0;

$output .= sprintf( '<div class="impress-carousel impress-listing-carousel-%s impress-carousel-shortcode owl-carousel owl-theme">', $display );
// The id set on the container and used by the output script to insert the listings into the page for this particular carousel
$carousel_id = uniqid('impress-carousel-');
$output .= sprintf( '<div id="%s" class="impress-carousel impress-listing-carousel-%s impress-carousel-shortcode owl-carousel owl-theme">', $carousel_id, $display);

// Used to hold agent data when matching for colistings.
$agent_data;
Expand Down Expand Up @@ -686,7 +688,7 @@ public function property_carousel_shortcode( $atts = array() ) {
$output = '
<script>
window.addEventListener("DOMContentLoaded", function(event) {
jQuery(".impress-listing-carousel-' . $display . '").owlCarousel({
jQuery("#' . $carousel_id . '").owlCarousel({
items: ' . $display . ',
' . $autoplay_param . '
nav: true,
Expand Down
6 changes: 4 additions & 2 deletions idx/widgets/impress-carousel-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ public function body( $instance ) {
$total = count( $properties );
$count = 0;

$output .= sprintf( '<div class="impress-carousel impress-listing-carousel-%s owl-carousel owl-theme">', $instance['display'] );
// The id set on the container and used by the output script to insert the listings into the page for this particular carousel
$carousel_id = uniqid('impress-carousel-');
$output .= sprintf( '<div id="%s" class="impress-carousel impress-listing-carousel-%s owl-carousel owl-theme">', $carousel_id, $instance['display'] );

// Used to hold agent data when matching for co-listings.
$agent_data;
Expand Down Expand Up @@ -230,7 +232,7 @@ public function body( $instance ) {
$output = '
<script>
window.addEventListener("DOMContentLoaded", function(event) {
jQuery(".impress-listing-carousel-' . $display . '").owlCarousel({
jQuery("#' . $carousel_id . '").owlCarousel({
items: ' . $display . ',
' . $autoplay . '
nav: true,
Expand Down

0 comments on commit 1863707

Please sign in to comment.