Skip to content

Commit 988e9ff

Browse files
authored
Show product collection limiter only if makes sense (#2502)
1 parent 2b439df commit 988e9ff

File tree

5 files changed

+74
-70
lines changed

5 files changed

+74
-70
lines changed

app/design/frontend/base/default/template/catalog/product/list/toolbar.phtml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* Product list toolbar
2424
*
25-
* @see Mage_Catalog_Block_Product_List_Toolbar
25+
* @var Mage_Catalog_Block_Product_List_Toolbar $this
2626
*/
2727
?>
2828
<?php if($this->getCollection()->getSize()): ?>
@@ -36,19 +36,20 @@
3636
<?php endif ?>
3737
</p>
3838

39-
<div class="limiter">
40-
<label><?php echo $this->__('Show') ?></label>
41-
<select onchange="setLocation(this.value)">
42-
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
43-
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
44-
<?php echo $_limit ?>
45-
</option>
46-
<?php endforeach ?>
47-
</select> <?php echo $this->__('per page') ?>
48-
</div>
49-
39+
<?php $availableLimits = $this->getAvailableLimit() ?>
40+
<?php if (count($availableLimits) > 1): ?>
41+
<div class="limiter">
42+
<label><?php echo $this->__('Show') ?></label>
43+
<select onchange="setLocation(this.value)">
44+
<?php foreach ($availableLimits as $_key => $_limit): ?>
45+
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
46+
<?php echo $_limit ?>
47+
</option>
48+
<?php endforeach ?>
49+
</select> <?php echo $this->__('per page') ?>
50+
</div>
51+
<?php endif ?>
5052
<?php echo $this->getPagerHtml() ?>
51-
5253
</div>
5354

5455
<?php if( $this->isExpanded() ): ?>
@@ -58,7 +59,7 @@
5859
<?php $_modes = $this->getModes(); ?>
5960
<?php if($_modes && count($_modes)>1): ?>
6061
<label><?php echo $this->__('View as') ?>:</label>
61-
<?php foreach ($this->getModes() as $_code=>$_label): ?>
62+
<?php foreach ($this->getModes() as $_code => $_label): ?>
6263
<?php if($this->isModeActive($_code)): ?>
6364
<strong title="<?php echo $_label ?>" class="<?php echo strtolower($_code); ?>"><?php echo $_label ?></strong>&nbsp;
6465
<?php else: ?>
@@ -72,13 +73,13 @@
7273
<div class="sort-by">
7374
<label><?php echo $this->__('Sort By') ?></label>
7475
<select onchange="setLocation(this.value)">
75-
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
76+
<?php foreach($this->getAvailableOrders() as $_key => $_order): ?>
7677
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif ?>>
7778
<?php echo $this->__($_order) ?>
7879
</option>
7980
<?php endforeach ?>
8081
</select>
81-
<?php if($this->getCurrentDirection() == 'desc'): ?>
82+
<?php if($this->getCurrentDirection() === 'desc'): ?>
8283
<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>
8384
<?php else: ?>
8485
<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>

app/design/frontend/base/default/template/page/html/pager.phtml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* Pager template
2424
*
25-
* @see Mage_Page_Block_Html_Pager
25+
* @var Mage_Page_Block_Html_Pager $this
2626
*/
2727
?>
2828
<?php if($this->getCollection()->getSize()): ?>
@@ -41,17 +41,18 @@
4141
</p>
4242
<?php endif ?>
4343

44-
<?php if($this->getShowPerPage()): ?>
45-
<div class="limiter">
46-
<label><?php echo $this->__('Show') ?></label>
47-
<select onchange="setLocation(this.value)">
48-
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
49-
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
50-
<?php echo $_limit ?>
51-
</option>
52-
<?php endforeach ?>
53-
</select> <?php echo $this->__('per page') ?>
54-
</div>
44+
<?php $availableLimits = $this->getAvailableLimit() ?>
45+
<?php if (count($availableLimits) > 1): ?>
46+
<div class="limiter">
47+
<label><?php echo $this->__('Show') ?></label>
48+
<select onchange="setLocation(this.value)">
49+
<?php foreach ($availableLimits as $_key => $_limit): ?>
50+
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
51+
<?php echo $_limit ?>
52+
</option>
53+
<?php endforeach ?>
54+
</select> <?php echo $this->__('per page') ?>
55+
</div>
5556
<?php endif ?>
5657

5758
<?php if($this->getLastPageNum()>1): ?>
@@ -86,7 +87,6 @@
8687
<?php endif ?>
8788
<?php endforeach ?>
8889

89-
9090
<?php if ($this->canShowNextJump()): ?>
9191
<li><a class="next_jump" title="" href="<?php echo $this->getNextJumpUrl() ?>">...</a></li>
9292
<?php endif ?>
@@ -107,7 +107,6 @@
107107
</li>
108108
<?php endif ?>
109109
</ol>
110-
111110
</div>
112111
<?php endif ?>
113112

app/design/frontend/default/iphone/template/page/html/pager.phtml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* Pager template
2424
*
25-
* @see Mage_Page_Block_Html_Pager
25+
* @var Mage_Page_Block_Html_Pager $this
2626
*/
2727
?>
2828
<?php if($this->getCollection()->getSize()): ?>
@@ -33,7 +33,6 @@
3333

3434
<?php if($this->getShowAmounts()): ?>
3535
<p class="amount">
36-
3736
<?php if($this->getLastPageNum()>1): ?>
3837
<?php echo $this->__('Items %s to %s of %s total', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
3938
<?php else: ?>
@@ -42,17 +41,18 @@
4241
</p>
4342
<?php endif ?>
4443

45-
<?php if($this->getShowPerPage()): ?>
46-
<div class="limiter">
47-
<label><?php echo $this->__('Show') ?></label>
48-
<select onchange="setLocation(this.value)">
49-
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
50-
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
51-
<?php echo $_limit ?>
52-
</option>
53-
<?php endforeach ?>
54-
</select> <?php echo $this->__('per page') ?>
55-
</div>
44+
<?php $availableLimits = $this->getAvailableLimit() ?>
45+
<?php if (count($availableLimits) > 1): ?>
46+
<div class="limiter">
47+
<label><?php echo $this->__('Show') ?></label>
48+
<select onchange="setLocation(this.value)">
49+
<?php foreach ($availableLimits as $_key => $_limit): ?>
50+
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
51+
<?php echo $_limit ?>
52+
</option>
53+
<?php endforeach ?>
54+
</select> <?php echo $this->__('per page') ?>
55+
</div>
5656
<?php endif ?>
5757

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

7070
<?php foreach ($this->getFramePages() as $_page): ?>
7171
<?php if ($this->isPageCurrent($_page)): ?>
72-
<option value="" class="current" selected="selected"><?php echo $_page ?></li>
72+
<option value="" class="current" selected="selected"><?php echo $_page ?></option>
7373
<?php else: ?>
7474
<option value="<?php echo $this->getPageUrl($_page) ?>"><?php echo $_page ?></option>
7575
<?php endif ?>

app/design/frontend/rwd/default/template/catalog/product/list/toolbar.phtml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* Product list toolbar
2424
*
25-
* @see Mage_Catalog_Block_Product_List_Toolbar
25+
* @var Mage_Catalog_Block_Product_List_Toolbar $this
2626
*/
2727
?>
2828
<?php if($this->getCollection()->getSize()): ?>
@@ -34,7 +34,7 @@
3434
<?php $_modes = $this->getModes(); ?>
3535
<?php if($_modes && count($_modes)>1): ?>
3636
<label><?php echo $this->__('View as') ?></label>
37-
<?php foreach ($this->getModes() as $_code=>$_label): ?>
37+
<?php foreach ($this->getModes() as $_code => $_label): ?>
3838
<?php if($this->isModeActive($_code)): ?>
3939
<strong title="<?php echo $_label ?>" class="<?php echo strtolower($_code); ?>"><?php echo $_label ?></strong>
4040
<?php else: ?>
@@ -48,13 +48,13 @@
4848
<div class="sort-by">
4949
<label><?php echo $this->__('Sort By') ?></label>
5050
<select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Sort By')) ?>">
51-
<?php foreach($this->getAvailableOrders() as $_key=>$_order): ?>
51+
<?php foreach($this->getAvailableOrders() as $_key => $_order): ?>
5252
<option value="<?php echo $this->getOrderUrl($_key, 'asc') ?>"<?php if($this->isOrderCurrent($_key)): ?> selected="selected"<?php endif ?>>
5353
<?php echo $this->__($_order) ?>
5454
</option>
5555
<?php endforeach ?>
5656
</select>
57-
<?php if($this->getCurrentDirection() == 'desc'): ?>
57+
<?php if($this->getCurrentDirection() === 'desc'): ?>
5858
<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>
5959
<?php else: ?>
6060
<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>
@@ -74,16 +74,19 @@
7474
</p>
7575
<?php endif ?>
7676

77-
<div class="limiter">
78-
<label><?php echo $this->__('Show') ?></label>
79-
<select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Results per page')); ?>">
80-
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
81-
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
82-
<?php echo $_limit ?>
83-
</option>
84-
<?php endforeach ?>
85-
</select>
86-
</div>
77+
<?php $availableLimits = $this->getAvailableLimit() ?>
78+
<?php if (count($availableLimits) > 1): ?>
79+
<div class="limiter">
80+
<label><?php echo $this->__('Show') ?></label>
81+
<select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Results per page')); ?>">
82+
<?php foreach ($availableLimits as $_key => $_limit): ?>
83+
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
84+
<?php echo $_limit ?>
85+
</option>
86+
<?php endforeach ?>
87+
</select>
88+
</div>
89+
<?php endif ?>
8790
</div>
8891

8992
<?php echo $this->getPagerHtml() ?>

app/design/frontend/rwd/default/template/page/html/pager.phtml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/**
2323
* Pager template
2424
*
25-
* @see Mage_Page_Block_Html_Pager
25+
* @var Mage_Page_Block_Html_Pager $this
2626
*/
2727
?>
2828
<?php if($this->getCollection()->getSize()): ?>
@@ -45,17 +45,18 @@
4545
<?php endif ?>
4646
<?php endif ?>
4747

48-
<?php if($this->getShowPerPage()): ?>
49-
<div class="limiter">
50-
<label><?php echo $this->__('Show') ?></label>
51-
<select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Results per page')); ?>">
52-
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
53-
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
54-
<?php echo $_limit ?>
55-
</option>
56-
<?php endforeach ?>
57-
</select>
58-
</div>
48+
<?php $availableLimits = $this->getAvailableLimit() ?>
49+
<?php if (count($availableLimits) > 1): ?>
50+
<div class="limiter">
51+
<label><?php echo $this->__('Show') ?></label>
52+
<select onchange="setLocation(this.value)" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Results per page')); ?>">
53+
<?php foreach ($availableLimits as $_key => $_limit): ?>
54+
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
55+
<?php echo $_limit ?>
56+
</option>
57+
<?php endforeach ?>
58+
</select>
59+
</div>
5960
<?php endif ?>
6061
</div>
6162
<?php endif ?>

0 commit comments

Comments
 (0)