Paginator Jump to Page text box

1 message Options
Embed this post
Permalink
Josh K

Paginator Jump to Page text box

Reply Threaded More More options
Print post
Permalink

I'm using the paginator helper in CakePHP to both sort columns and
move between pages. I've modified $paginator->counter() in the Cake
libs to echo something like "Viewing page <input type="text"
value="$pagenumber"> of 167.  I want to allow my users to jump to any
page by typing it in the textbox counter and pressing enter. Here's my
code:

<?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

$strippn = preg_replace('/\/page:[0-9]\d{0,11}/','',$url);

 ?>
<script type="text/javascript">
function append(pn) {
pn.action = '<?php echo $strippn."/page:"; ?>' + pn.pagenumber.value;
}
</script>
        <form class="pagination" name="pagination" method="post"
action="" onsubmit="append(this);">
          <?php echo $paginator->counter(); ?>
        </form>

The above solution works with the paginator, but there's got to be
something better that isn't as "dirty".  Any ideas? Maybe something
like this is already built into the paginator?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---