Hi Melanie thanks for your kind reply. I meant general sorting, not necessarily in the view, something like SELECT * FROM User inner join Group order by Group.name
I think it's quite amazing such a basic feature could not be achieved with CakePHP, a workaround has to exist (different from manually sorting pagination results). On 22 Ott, 16:33, Melanie Sommer <melanie-som...@mailinator.com> wrote: > > Hi > > does anyone know if it's possible to order by a contained fields? It > > seems to me like a simple task but I'm unable to manage it.. I have a > > User model associated with a Group field and I'd like to order User by > > Group.name. > > Do you mean paginator function sort() ? There you simpy need to type > $paginator->sort('Group','Group.name'); > > This only works if Group is directly related to your user, by > belongsTo for example. I did not manage to get it work with any models > that are not directly related with the current model and noone was > able to answer me this question by now. > > Here:http://bakery.cakephp.org/articles/view/advanced-pagination-1-2 > is written: > "Cake 1.2 is still in development. I feel obligated to inform the > reader of known weaknesses in pagination, before they dive in and > start using it. There are only two things I know of which have been > any hinderance to anybody. > 1. Sorting by another model - Perhaps your model you want to paginate > with has a belongsTo relationship to another model. You may want to > sort by that other model. Currently this is not possible for security > reasons. I'm told it will be done before Cake 1.2 becomes official. > For now though, I am sorry you can only sort by the Model you are > paginating with." > > So sorting by directly related models seems to be a rather new > feature, so I fear it is generally not possible (without a lot of own > code) to sort by models not directly related. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---