I don't mind having to specify the model as this has to got be better than hacking the core. :)
Alas, when I try to use 'direction' in $paginator->link() it still gets ignored, so I will still need to use $html->link on those. On Mar 22, 2:04 pm, Martin Westin <[email protected]> wrote: > The fix changed the behavior for all simple (single-model) paginations > so that they now require the modelname in sort() to work. I suspect > this was not intended? > > http://groups.google.com/group/cake-php/browse_thread/thread/00fc597c... > > On Mar 22, 1:51 pm, Mike Cook <[email protected]> wrote: > > > FYI > > > The latest CakePHP release (1.2.2.8120) fixes the problems I was > > having, now $paginator->link() can used to get the desired results. On > > my initial check, everything seems to be working perfect. > > > Many thanks to the developers! > > > Mike > > > On Feb 27, 11:11 pm, Mike Cook <[email protected]> wrote: > > > > As there was no reply I ended up posting a bug ticket for this. I'm > > > posting the result here for future searches on the subject. > > > > Apparently this inheritance is the intended behavior of the Paginator > > > helper. Personally this makes no sense to me, but I guess there must > > > be good reason for it. > > > > If you need a link that doesn't adapt to the current parameters (e.g. > > > having a permanent direction:desc) then it's recommended to use > > > HtmlHelper::link. The links generated with this do not change, thus > > > giving the desired results. > > > > For example, in my index.ctp view I changed; > > > > echo $paginator->link('Recent', array('sort'=>'released',> > > > 'direction'=>'desc'); > > > > to > > > > echo $html->link('Recent', array('sort' => 'released', 'direction' => > > > 'desc')); > > > > -- Mike > > > > On Feb 15, 11:49 am, Mike Cook <[email protected]> wrote: > > > > > I had posted about this previously but I guess the title and > > > > explanation I used were not very good. Hopefully this will be better. > > > > > Here is my code; > > > > > // Controller > > > > function index() { > > > > $this->paginate['Book'] = array( > > > > 'contain' => array('Author', 'Language', 'Genre'), > > > > 'order' => 'title asc' > > > > ); > > > > $this->set('books', $this->paginate()); > > > > } > > > > > // index.ctp view > > > > <ul> > > > > <li><?php echo $paginator->sort('Title', 'title'); ?></li> > > > > <li><?php echo $paginator->link('Recent', array('sort'=>'released', > > > > 'direction'=>'desc'); ?></li> > > > > <li><?php echo $paginator->sort('Language', 'Language.code'); ?></ > > > > li> > > > > </ul> > > > > > When the view loads the links are; > > > > >http://localhost/books/index/page:1/sort:title/direction:deschttp://l... > > > > > (I am trying to force the 'Recent' sort order to always default to > > > > 'desc') > > > > > These all work as expected when the link is clicked for the first time > > > > on the initial page load. The problem I am having is with the > > > > $paginator->link(‘Recent’, ...) sort, which is inheriting the model > > > > from the previous sort that was made. > > > > > So, if I click ‘Title’ followed by the ‘Recent’ link, I get this URL; > > > > >http://localhost/books/index/page:1/sort:Book.released/direction:desc > > > > > As you can see, the link has inherited ‘Book.released’. If I click > > > > ‘Language’ then the released link becomes ‘Language.released’. The > > > > direction is also being inherited depending on the previous sort > > > > order. > > > > > Even if I set the link in the view to use ‘Book.released’; > > > > > $paginator->link('Recent', array('sort'=>'Book.released', > > > > 'direction'=>'desc'); > > > > > It still inherits the model, ‘Language.released’. The $paginator->sort > > > > always plays nice as the 'Title' link remains as 'sort:title'. > > > > > So, is this a bug with $paginator->link, and if not can anyone advise > > > > me on how to get it working properly? > > > > > Thanks, > > > > Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" 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 -~----------~----~----~----~------~----~------~--~---
