Jump to content

Layered Navigation Breaks Product Count


Recommended Posts

Hi all, 

 

Having troubles with the Layered Navigation block on my website at http://casshudson.monkeydrupal.com/13-casters.

 

The pagination works but the "Showing 1 - 10" count goes nuts when going to any other page using the pagination links.

 

I read here that the problem could be with the # that Layered Nav is appending to the pagination links. I can see this when I hover my mouse over any of the pagination links.

 

For example, hovering over page 2 link shows "http://casshudson.monkeydrupal.com/13-casters#/page-1" -- when in fact the correct URL would be http://casshudson.monkeydrupal.com/13-casters?p=2. As a matter of fact even hovering over the Page 10 link shows the exact same URL (http://casshudson.monkeydrupal.com/13-casters#/page-1). Why page-1? Shouldn't this be page 10?

 

Anyone ever have any issues like this? I've read quite a bit of similar experiences but haven't been able to find anything that works.

post-1179385-0-00015300-1453329149_thumb.jpg

Link to comment
Share on other sites

Hmmm... so themes/my_module/js/modules/blocklayered.js line 320ish assigns a variable nbPerPage equal to a selected value on the #nb_item DOM node... which is odd because the #nb_item node is not a select box at all but rather a hidden input field. How could this ever evaluate to anything other than false??

 

Changing lines 316 - 319 of blocklayered.js from 

if ($('#nb_item option:selected').length == 0)
    var nbPerPage = nb_products;
else
    var nbPerPage = parseInt($('#nb_item option:selected').val());

to 

if ($('#nb_item option:selected').length == 0)
    var nbPerPage = $('#nb_item').data('perpage');
else
    var nbPerPage = parseInt($('#nb_item option:selected').val());

Making this change sets up to then tweak pagination.tpl and give us a value to work with:

 

Change line 75 from 

<input name="n" id="nb_item" class="hidden" value="{$nb_products}" />

to

<input name="n" id="nb_item" class="hidden" value="{$nb_products}" data-perpage="{$products_per_page}" />

All of this may be a total hack - I'm not saying it isn't - but it's what worked for me to fix my layered navigation product counts during pagination.

 

If someone knows of a better answer please follow up!

Edited by badcrocodile (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...