I have a front page, served from a modified PagesController, that has
an element which calls requestAction('posts/front_page') (I know, I
know) to grab the most recent Posts. At the bottom of the list of
posts is a link leading to posts/index. What I'd really like to do is
use paginate() instead of find() so I can set up pagination links.

I'd really rather not use posts/index.ctp as the home page for the
site. The idea would be to have the pagination links at the bottom of
the main page point to posts/index, though I'd actually be using ajax
to refresh the list on the main page.

Now, given that I'm using requestAction() this doesn't seem possible
... but I'm trying anyway.

Browsing through the Controller source, I see that I need to have
$this->params['paging'] set. So, I added Paginator to the controller's
helpers array and modified the PostsController's action like:

public function front_page()
{
        $posts = $this->paginate('Post');
        return array('posts' => $posts, 'paging' => $this->params['paging']);
}

In the element, I have (and I know this isn't a great idea):

$result = $this->requestAction('posts/front_page');
$this->params['paging'] = $result['paging'];

foreach ($result['posts'] as $post)
{
    ...

Now, of course, this isn't sufficient, because PaginatorHelper hasn't
been intialized with the params in PagesController:

Notice (8): Undefined index:  pageCount
[CORE/cake/libs/view/helpers/paginator.php, line 473]

So, before I head further down this road, does anyone have a
suggestion for how to do this ... properly?

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

Reply via email to