Indeed, there is. At least, if you're trying to do what I did. Your
question isn't very clear.

I needed to paginate posts on the front page of a site. This page is
served up by a customised PagesController (PublicStaticController--a
bit of a joke that I won't get into). Anyway, I'll just show you the
comment in the PostsController:

-- snip --
This method is called from an element that's included in the front
page view. There's a bit of black magic happening here in order to
give the static view a PaginatorHelper with the correct params.
Basically, PublicStaticController has Paginator in its $helpers array.
After the paginate() here, the params are swapped into the helper. The
front_page element then passes a url array pointing to posts/index to
the $paginator options.
-- snip --

public function front_page()
{
        $posts = $this->paginate('Post');
        ClassRegistry::getObject('view')->loaded['paginator']->params = 
$this->params;
        $categories = $this->Post->fetchCategoryLinks();
        return compact('posts', 'categories');
}

$categories is just a list of Post categories. You can ignore that.

At the bottom of the front_page element, I include my paginator_links
which I use for all paginated views. However, I added a url array
which is in turn passed to Paginator's options.

front_page.ctp:

echo $this->element(
        'paginator_links',
        array(
                'url' => array(
                        'controller' => 'posts',
                        'action' => 'index'
                )
        )
);

At the top of paginator_links.ctp:

$paginator->options(
        array('url' => isset($url) ? $url : $this->passedArgs)
);

On Mon, Apr 20, 2009 at 12:06 PM, Mech7 <chris.de....@gmail.com> wrote:
>
> Is there anyway to get the pagination to work without redirecting to a
> different controller ? :)
> >
>

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