Ideally, you should be able to create post_count as a virtualField and
then sort by that, by as the cookbook states, the paginator can't
order by virtualFields of associated models, so you wouldn't be able
to sort by it. But there are two simple workarounds for this:
http://book.cakephp.org/view/1608/Virtual-fields

On Jun 13, 4:11 am, DigitalDude <[email protected]> wrote:
> Hey,
>
> I have a problem here and need to fix it. It's about the following
> situation:
>
> I have a model "User" that has a relation to some entrie, let's say
> "Posts". I want to paginate the User-Model and add a counting of the
> user's posts to my index of Users. So I will have the following table-
> structure in my view:
>
> Id Name Posts Actions
> 2  Ben      5       view/edit/delete
> 5  Mary    8       view/edit/delete
>
> The first two columns are easy to sort, but HOW can I sort my
> paginated user-array by the count of the related Post-entries?
>
> I would really appreciate some help here, because I just cannot find a
> way to do this... :(
>
> Regards,
>
> DD

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to