Skip to content

Commit

Permalink
Show product collection limiter only if makes sense (#2502)
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano authored Aug 30, 2022
1 parent 2b439df commit 988e9ff
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Product list toolbar
*
* @see Mage_Catalog_Block_Product_List_Toolbar
* @var Mage_Catalog_Block_Product_List_Toolbar $this
*/
?>
<?php if($this->getCollection()->getSize()): ?>
Expand All @@ -36,19 +36,20 @@
<?php endif ?>
</p>

<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)">
<?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> <?php echo $this->__('per page') ?>
</div>

<?php $availableLimits = $this->getAvailableLimit() ?>
<?php if (count($availableLimits) > 1): ?>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach ($availableLimits 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> <?php echo $this->__('per page') ?>
</div>
<?php endif ?>
<?php echo $this->getPagerHtml() ?>

</div>

<?php if( $this->isExpanded() ): ?>
Expand All @@ -58,7 +59,7 @@
<?php $_modes = $this->getModes(); ?>
<?php if($_modes && count($_modes)>1): ?>
<label><?php echo $this->__('View as') ?>:</label>
<?php foreach ($this->getModes() as $_code=>$_label): ?>
<?php foreach ($this->getModes() as $_code => $_label): ?>
<?php if($this->isModeActive($_code)): ?>
<strong title="<?php echo $_label ?>" class="<?php echo strtolower($_code); ?>"><?php echo $_label ?></strong>&nbsp;
<?php else: ?>
Expand All @@ -72,13 +73,13 @@
<div class="sort-by">
<label><?php echo $this->__('Sort By') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<?php foreach($this->getAvailableOrders() as $_key => $_order): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach ?>
</select>
<?php if($this->getCurrentDirection() == 'desc'): ?>
<?php if($this->getCurrentDirection() === 'desc'): ?>
<a href="<?php echo $this->getOrderUrl(null, 'asc') ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Set Ascending Direction')) ?>"><img src="<?php echo $this->getSkinUrl('images/i_desc_arrow.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Set Ascending Direction')) ?>" class="v-middle" /></a>
<?php else: ?>
<a href="<?php echo $this->getOrderUrl(null, 'desc') ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Set Descending Direction')) ?>"><img src="<?php echo $this->getSkinUrl('images/i_asc_arrow.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Set Descending Direction')) ?>" class="v-middle" /></a>
Expand Down
27 changes: 13 additions & 14 deletions app/design/frontend/base/default/template/page/html/pager.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Pager template
*
* @see Mage_Page_Block_Html_Pager
* @var Mage_Page_Block_Html_Pager $this
*/
?>
<?php if($this->getCollection()->getSize()): ?>
Expand All @@ -41,17 +41,18 @@
</p>
<?php endif ?>

<?php if($this->getShowPerPage()): ?>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)">
<?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> <?php echo $this->__('per page') ?>
</div>
<?php $availableLimits = $this->getAvailableLimit() ?>
<?php if (count($availableLimits) > 1): ?>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach ($availableLimits 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> <?php echo $this->__('per page') ?>
</div>
<?php endif ?>

<?php if($this->getLastPageNum()>1): ?>
Expand Down Expand Up @@ -86,7 +87,6 @@
<?php endif ?>
<?php endforeach ?>


<?php if ($this->canShowNextJump()): ?>
<li><a class="next_jump" title="" href="<?php echo $this->getNextJumpUrl() ?>">...</a></li>
<?php endif ?>
Expand All @@ -107,7 +107,6 @@
</li>
<?php endif ?>
</ol>

</div>
<?php endif ?>

Expand Down
28 changes: 14 additions & 14 deletions app/design/frontend/default/iphone/template/page/html/pager.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Pager template
*
* @see Mage_Page_Block_Html_Pager
* @var Mage_Page_Block_Html_Pager $this
*/
?>
<?php if($this->getCollection()->getSize()): ?>
Expand All @@ -33,7 +33,6 @@

<?php if($this->getShowAmounts()): ?>
<p class="amount">

<?php if($this->getLastPageNum()>1): ?>
<?php echo $this->__('Items %s to %s of %s total', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
<?php else: ?>
Expand All @@ -42,17 +41,18 @@
</p>
<?php endif ?>

<?php if($this->getShowPerPage()): ?>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)">
<?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> <?php echo $this->__('per page') ?>
</div>
<?php $availableLimits = $this->getAvailableLimit() ?>
<?php if (count($availableLimits) > 1): ?>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)">
<?php foreach ($availableLimits 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> <?php echo $this->__('per page') ?>
</div>
<?php endif ?>

<?php if($this->getLastPageNum()>1): ?>
Expand All @@ -69,7 +69,7 @@

<?php foreach ($this->getFramePages() as $_page): ?>
<?php if ($this->isPageCurrent($_page)): ?>
<option value="" class="current" selected="selected"><?php echo $_page ?></li>
<option value="" class="current" selected="selected"><?php echo $_page ?></option>
<?php else: ?>
<option value="<?php echo $this->getPageUrl($_page) ?>"><?php echo $_page ?></option>
<?php endif ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Product list toolbar
*
* @see Mage_Catalog_Block_Product_List_Toolbar
* @var Mage_Catalog_Block_Product_List_Toolbar $this
*/
?>
<?php if($this->getCollection()->getSize()): ?>
Expand All @@ -34,7 +34,7 @@
<?php $_modes = $this->getModes(); ?>
<?php if($_modes && count($_modes)>1): ?>
<label><?php echo $this->__('View as') ?></label>
<?php foreach ($this->getModes() as $_code=>$_label): ?>
<?php foreach ($this->getModes() as $_code => $_label): ?>
<?php if($this->isModeActive($_code)): ?>
<strong title="<?php echo $_label ?>" class="<?php echo strtolower($_code); ?>"><?php echo $_label ?></strong>
<?php else: ?>
Expand All @@ -48,13 +48,13 @@
<div class="sort-by">
<label><?php echo $this->__('Sort By') ?></label>
<select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Sort By')) ?>">
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
<?php foreach($this->getAvailableOrders() as $_key => $_order): ?>
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif ?>>
<?php echo $this->__($_order) ?>
</option>
<?php endforeach ?>
</select>
<?php if($this->getCurrentDirection() == 'desc'): ?>
<?php if($this->getCurrentDirection() === 'desc'): ?>
<a href="<?php echo $this->getOrderUrl(null, 'asc') ?>" class="sort-by-switcher sort-by-switcher--desc" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Set Ascending Direction')) ?>"><?php echo $this->__('Set Ascending Direction') ?></a>
<?php else: ?>
<a href="<?php echo $this->getOrderUrl(null, 'desc') ?>" class="sort-by-switcher sort-by-switcher--asc" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Set Descending Direction')) ?>"><?php echo $this->__('Set Descending Direction') ?></a>
Expand All @@ -74,16 +74,19 @@
</p>
<?php endif ?>

<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Results per page')); ?>">
<?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>
</div>
<?php $availableLimits = $this->getAvailableLimit() ?>
<?php if (count($availableLimits) > 1): ?>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Results per page')); ?>">
<?php foreach ($availableLimits 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>
</div>
<?php endif ?>
</div>

<?php echo $this->getPagerHtml() ?>
Expand Down
25 changes: 13 additions & 12 deletions app/design/frontend/rwd/default/template/page/html/pager.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Pager template
*
* @see Mage_Page_Block_Html_Pager
* @var Mage_Page_Block_Html_Pager $this
*/
?>
<?php if($this->getCollection()->getSize()): ?>
Expand All @@ -45,17 +45,18 @@
<?php endif ?>
<?php endif ?>

<?php if($this->getShowPerPage()): ?>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Results per page')); ?>">
<?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>
</div>
<?php $availableLimits = $this->getAvailableLimit() ?>
<?php if (count($availableLimits) > 1): ?>
<div class="limiter">
<label><?php echo $this->__('Show') ?></label>
<select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Results per page')); ?>">
<?php foreach ($availableLimits 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>
</div>
<?php endif ?>
</div>
<?php endif ?>
Expand Down

0 comments on commit 988e9ff

Please sign in to comment.