0

I have pagination on my category page, however, I'm having a few problems with it.

  1. Supposedly, if you select the limit on the dropdown on the toolbar, the number of products that would display would change. Say if you select 20 on the dropdown, there should be 20 products on the first page instead of 5. However, after I've made some customizations on the paging (moved paging at the bottom of the list, added first and last buttons), this dropdown no longer works. Is there something I need to add or change in the code for this to work?

  2. I've added a text before the paging that says page n of n. Then, I made some changes on the php file to test how I can modify the limit dropdown. Then I changed the page then the limit. So there are instances wherein the page becomes Page 5 of 2. How can I fix this?

Update: I've managed to fix problem 2 by making some comparisons so that one's fixed. For problem 1, I don't have much code to show since I didn't make any changes to toolbar.phtml where the dropdown is but anyway, here's the code inside phtml related to the limit.

<select>
            <?php foreach ($this->getAvailableLimit() as  $_key=>$_limit): ?>
                <option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
                    <?php echo $_limit ?>
                </option>
            <?php endforeach; ?>
        </select>

With that code, the page is supposed to reload with ?limit=n on the url which means it will display n number of items per page but it's not.

4

1 回答 1

0

I've managed to fix both problems. Hope this helps someone else.

For problem 1. I compared the toolbar.phtml file from the server I'm working on and another toolbar.phtml from an older project where it was working. Apparently, the select tag was replaced so the onchange method was missing. I simply added

onchange="setLocation(this.value)" 

on the select tag and it worked.

For problem 2, since I compared the current page with the value of the last page then made my modifications accordingly. Something like:

<?php if($toolbar->getCurrentPage() > $toolbar->getLastPageNum()) { ?>
于 2013-07-11T06:32:20.317 回答