badcrocodile Posted January 20, 2016 Share Posted January 20, 2016 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. Link to comment Share on other sites More sharing options...
badcrocodile Posted January 21, 2016 Author Share Posted January 21, 2016 UPDATE: Changing themes to bootstrap seems to fix it -- so my question at this point is what could be causing this behavior in my theme? Link to comment Share on other sites More sharing options...
badcrocodile Posted January 21, 2016 Author Share Posted January 21, 2016 (edited) 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 January 21, 2016 by badcrocodile (see edit history) 1 Link to comment Share on other sites More sharing options...
badcrocodile Posted January 21, 2016 Author Share Posted January 21, 2016 My theme wasn't calling nbr-product-page.tpl anywhere. It was commented out at some point. That's why layered nav wasn't working because nbr-product-page.tpl is what creates the #nb_item select element that I was missing. Link to comment Share on other sites More sharing options...
Shonen Posted November 14, 2017 Share Posted November 14, 2017 Hello, November 2017 here, and your answer is still relevant. This hack works perfectly for me, with this exact lines, thank you for sharing. Bless you. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now