This is what I did.
Page <?=$paginator->counter(); ?>
<?
if ($paginator->current() != 1) {
$this->params['pass']['page'] = 1;
echo $paginator->link("<< First", $this->params['pass'])." | ";
} else {
echo "<< First | ";
}
?>
<?=$paginator->prev('< Previous', null, null, array('class' =>
'disabled')); ?> |
<?=$paginator->next('Next >', null, null, array('class' =>
'disabled')); ?>
<?php
if ($paginator->current() !=
$paginator->params['paging'][$paginator->defaultModel()]['pageCount']) {
$this->params['pass']['page'] =
$paginator->params['paging'][$paginator->defaultModel()]['pageCount'];
echo " | ".$paginator->link("Last >>", $this->params['pass']);
} else {
echo " | Last >>";
}
?>
But there are 2 problems with this approach.
1. my main controller is messages, so if I access the page with
<host>/messages, then it properly creates the url as /messages/page:1 or
/messages/page:xx, etc., If I change the routes to goto /messages if I hit
'/' root, then it creates url like /page:1 and /page:<last page> instead of
creating /messages/index/page:1, where as the next and previous links are
created correctly.
2. Sorting, if you click on any sorting and click on the first and last page
link this way it misses the sorting information and throws error page.
Probably I am missing something here.. can somebody help me ?
http://ps.namo-namaha.net/messages
http://dev.ps.namo-namaha.net/messages
Regards
Humble
On 4/13/07, byBartus <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> What I made to achieve the page numbers was simpler than to hack the
> core, as Nate explained in another one thread.
>
>
> ==== in the view (list.ctp) ===
>
> <?php
> $params = $paginator->params();
>
> echo $paginator->prev('<< Prev');
>
> echo '<ul>';
>
> for ($i = 1; $i <= $params['pageCount']; $i++) {
> if ($i == $params['page']) {
> echo '<li><strong>'.$i.'</strong></li>';
> } else {
> echo '<li>'.$paginator->link($i, array('page'
> => $i)).'</li>';
> }
> }
>
> echo '</ul>';
>
> echo $paginator->next('Next >>');
> ?>
>
> I only added the UL and LI itens for the numbers, that I think to be
> more semantic than EM.
>
> But to achieve the the link to the first or last page i do not know
> what to do.
>
> Perhaps this gives you another idea.
>
> T+
>
>
>
>
> On Apr 12, 9:37 am, "francky06l" <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I am upgrading an application to cake 1.2 and needed to convert to the
> > new paginator.
> > I have amended the paginator helper to include :
> >
> > pageNumber : to get the number of pages
> > hasFirst: to display an eventual First link
> > hasLast: to display an eventual Last link
> >
> > For this I needed to modify slightly the _paginLink method (only
> > little, because it always takes the current page + step ..etc ..)
> >
> > I also have added '<em></em.>' in the paginator's numbers function in
> > order to make easier to apply a style on the current page (which is
> > not a link)..
> >
> > I do not know if this modifications should be shared (maybe someone
> > better than me can check the code), I can post the code here if that
> > helps someone ..
> > I also have done a Component to work with the paginate in controller,
> > in order to save the conditions in sessions and be able to do a "back
> > to list", when the list have been replaced by an edit view .. but I am
> > sure it does not handle all cases (sort etc ...).
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---