I got it working. Thanks a bunch for setting me straight!
For posterity, this is what I needed:
public function index()
{
/* defaults
*/
$page = 1;
$limit = $this->SearchIndex->limit;
$models = array();
/* check form query
*/
if (!empty($this->data))
{
if (empty($this->data['Search']['q']))
{
$this->flash('no search string');
}
$q = $this->data['Search']['q'];
// and limit & models ...
}
else if (!empty($this->params['named']))
{
/* in URL
*/
if (empty($this->params['named']['q']))
{
$this->flash('no search string');
}
$q = $this->params['named']['q'];
// and limit & models ...
$page = $this->params['named']['page'];
}
if (isset($q))
{
/* now make sure things are clean
*/
App::import('Sanitize');
$q = Sanitize::escape($q, 'default');
$limit = intval($limit);
// ...
/* set this for Paginator
*/
$this->passedArgs = array(
'q' => $q,
'models' => implode(',',$models),
'limit' => $limit
);
$this->SearchIndex->searchModels($models);
$this->paginate = array(
'limit' => $limit,
'page' => $page,
'conditions' => "MATCH(SearchIndex.data)
AGAINST('${q}' IN BOOLEAN MODE)"
);
$this->set('results', $this->paginate('SearchIndex'));
$this->set('search_string', $q);
}
// etc.
}
views/elements/paginator_links.ctp:
$paginator->options(array('url' => $this->passedArgs));
<div class="PaginationLinks">
<?= $paginator->prev(
'20',
array(
'url' => array('limit' => 20),
'class' => 'Limit LimitPrev',
'title' => 'previous, limit 20 results'
)
) ?>
...
Works a treat! I *knew* what I'd done was hackish. While it worked, I
was sure there had to be a better way. I'm glad I checked in.
On Sat, Jan 10, 2009 at 6:06 PM, Miles J <[email protected]> wrote:
>
> Ive done it that way before, and it also shows that in the cookbook.
>
> http://book.cakephp.org/view/166/Pagination-in-Views
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---