I have an element  for displaying Paginator's links which I can drop
into a pagination view, both above and below a set of paged data. So
far, it works just fine. But, I've had to do some fiddling to deal
with a query string and I'm really uncertain whether what I've done is
the best way. Of course, it might be the only way.

I've posted a basic version of the element here:
http://bin.cakephp.org/view/456211020

If the query string is set in the controller, it's added to
$this->params['url']['?'] just before Paginator's options are set with
$this->params['url']. This way, the links it creates get the query
string appended. So far, so good.

 But, in order to make "limit links" (next 20, next 30, etc.) the
limit in the URL's query string must first be removed or one gets
something like:

/search/index/page:2/limit:20?q=foobar&limit=10&models=Member,Publication,Post

So, instead of echoing $paginators's next, prev, etc. methods
directly, I have to write them to variables, then check, once again,
for query string:

if (isset($query_string))
{
        $this->params['pass']['?'] = preg_replace('/&limit=[0-9]+/', '',
$query_string);
        
        /* set the options once again
         */
        $paginator->options(array('url' => $this->params['pass']));

        /* empty for next element invocation
         */
        $this->params['pass']['?'] = null;
}

... then go on to write the limit links and, finally, echo all of
those into my links div.

So, my question is: well, is this the best I can do? It seems a bit
hackish, for one, to do this in an element. Also, the element can be
dropped into a view several times.

I'd appreciate any comments. I'm wondering if this functionality
should be rolled into PaginatorHelper. If others agree, I'll write
something up and post it to Trac.

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