I am working on a user profile type view/controller action. On the
pages, there will be an Activity Feed area, which displays facebook-
style recent user activities. Each activity can be commented on. The
commenting is all handled via AJAX, and I've got add/edit/delete stuff
working nicely. The next step is to make each block of comments
paginated (also AJAX).

A mockup of the view is something like this:

=======================================
User Profile

Activities

        user did something
                comment
                comment
                comment
                << 1 2 3 >>

        user did something else
                comment
                comment
                comment
                << 1 2 3 >>
=======================================

Each block of comments needs to be paginated (AJAX) separately.

I've read this site on paginating multiple models, but that isn't what
I need to do:
http://debuggable.com/posts/how-to-have-multiple-paginated-widgets-on-the-same-page-with-cakephp:48ad241e-b018-4532-a748-0ec74834cda3

I basically need to paginate multiple sets of data from the same
model, with different filter conditions (eg: the activity_feed_id).

This is how I fetch all of the data associated with the user in the
user controller:

=======================================
$user = $this->User->find('first', array(
        'contain' => array(
                'ActivityFeed' => array(
                        'order' => 'ActivityFeed.created DESC',
                        'limit' => 30,
                        'Comment' => array(
                                'order' => 'Comment.created ASC',
                                'limit' => 15,
                                'User' => array(
                                        'fields' => array('id', 'username', 
'created'),
                                ),
                        ),
                ),
        ),
));
=======================================

My first hope is that there is an elegant way to build the pagination
I need into this singular User->find() call.

A fallback would be to remove the Comment model from the contained
associations. Then, I could run a series of Comment->paginate() calls,
for each ActivityFeed that is found. something like:

=======================================
foreach ($user['ActivityFeed'] as $key => $activityFeed) {

        $this->paginate = array('what goes here?');

        $options = array('this is probably just associating the foreign keys
I need to filter the comments by activity feed');

        $comments = $this->paginate('Comment', $options);

        $user['ActivityFeed'][$key]['Comment'] = $comments;
}
=======================================

How can I go about setting up the paginator to not have separate
arrays of data based just on model name (since everything is coming
from the same model), but on some other arbitrary information
(ActivityFeed ID and its associated comments)? Once I get this set up,
I think adapting the multiple paginated widgets view calls to the
paginator functions should be fairly straightforward.

--~--~---------~--~----~------------~-------~--~----~
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