Carousel products display

  • Posts: 1119
  • Thank you received: 114
4 years 5 months ago #311970

Hi,

We been trying to configure module to use carousel under product page.

This module will display recently viewed products. Inside module config we set 2 rows and 5 columns. Total of products will be 10 and 5 visible as this is what i expect. It looks fine when you have 5 or more products showing in that module. However as this module is set to display only recently viewed items, the display of products until you reach 5 is wrong.

As example. If it shows only 1, it shows full width, i expect it show 1 with the width as it would be as 5, as set per configuration....

I have looked into carousel.php and found that variable "$products" will return current visible products in:

$options['responsive'] = '{0:{items:2, slideBy:1}, 768:{items:3, slideBy:'.$slideByFor2.'}, 992:{items:'.$products.'}}';

so if i set 5 manually inside:
992:{items:'.$products.'}

It looks fine...

So shouldn't it return the column number u set in the configuration tab? As this is what it does if recently viewed settings are not used...

I hope you understand the issue.

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
4 years 5 months ago #311984

Hi,

This was made on purpose to avoid elements of the carousel to be duplicated to fit in the number of columns configured in the settings.
The issue was actually reported here more than 1 year ago:
www.hikashop.com/forum/5-support-en-fran...-content.html#284976

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 5 months ago #311987

Hi,

Bad, i do not read French but anyway i had to use:

$items = $this->params->get('columns');

and change this:
if($products > 1) {

to this:
if($products > 0) {

And that fixed the issue.

It seems there should be extra check if less products are showing then selected in columns settings.

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 1119
  • Thank you received: 114
4 years 5 months ago #311988

Another thing. It would be great if there would be some params inside module configuration where you could define the responsive breakpoints and items to it. This would allow to have different look per module. Easy solution but very useful...

Right now it use same options defined in:

$options['responsive']

Thank you

Please Log in or Create an account to join the conversation.

  • Posts: 81361
  • Thank you received: 13035
  • MODERATOR
4 years 5 months ago #311994

Hi,

Doing the modification you suggest didn't work on my end. Instead it duplicated the elements until the carousel had enough of them to display all the columns.
So I did some research and debug and found that this is an issue with the carousel library:
github.com/OwlCarousel2/OwlCarousel2/issues/2091
So I've actually modified the code you were pointing at to:

if($nb_products < $this->params->get('columns')) {
	$options['loop'] = false;
	$columns = $this->params->get('columns');
	$products = $this->params->get('item_by_slide');
} else {
	$columns = min($nb_products, $this->params->get('columns'));
	$products = min($nb_products, $this->params->get('item_by_slide'));
}
That way, the loop is deactivated if there are not enough elements to make one slide, avoiding the duplication issue while still displaying the elements with the expected width.

Regarding the "responsive" option of the carousel library, changing this is too complex for a normal user. I believe it's best done as a view override for power users like you.

Please Log in or Create an account to join the conversation.

Time to create page: 0.061 seconds
Powered by Kunena Forum