2

I would like to use pagination by text box where client can type the number of product page and click go/submit button.

Qaisar Satti
  • 32,469
  • 18
  • 85
  • 137
Wine Chit
  • 49
  • 5

3 Answers3

1

you must insert the code below in

\app\design\frontend\YOURTEMPLATE\default\template\page\html\pager.phtml

or

\app\design\frontend\YOURTEMPLATE\default\template\catalog\product\list\toolbar.phtml
John Doe
  • 41
  • 5
1
<?php  $totalpage=$collection->getLastPageNumber(); //get total number of pages
$currentUrl = Mage::helper('core/url')->getCurrentUrl();

 ?>
<input type="text" name="pager" id="pager"> <input type="button" value="go" onClick="gopage()">

<script>
function gopage()
{
  vale=$('pager').getValue();
  if(vale >=<?php echo totalpage; ?>) {
  window.location='<?php echo currentUrl ?>?page'+vale;
   }
}
</script>
Qaisar Satti
  • 32,469
  • 18
  • 85
  • 137
0
<?php  $totalpage=$_productCollection->getLastPageNumber(); //get total number of pages
        echo "Total Page is " . $totalpage;
        $currentUrl = Mage::helper('core/url')->getCurrentUrl();
        //echo $currentUrl;
         ?>
            | Enter Page Number: <input type="text" name="pager" id="pager"> <input type="button" value="Go To Page" onClick="gopage()">

        <script>
        function gopage()
        {
            var x = '<?php echo $currentUrl; ?>';
            //alert(x);
            var url = x.split('?')[0];
            //alert(url);

         vale=document.getElementById("pager").value;
          //alert(vale);

          if(isNaN(vale)==true || Number(vale) >'<?php echo $totalpage; ?>') {
                alert('Your maximun page number is ' + '<?php echo $totalpage; ?>');

           }
           else{
                window.location=url+'?p='+vale;     
           }    
        }
        </script>
Wine Chit
  • 49
  • 5