On my search results page I display results from 3 different models. These are displayed in their own containers on the page using CListView widgets.
Now I am using POST as the submit method for the query form. I wish to use the ajax style pagination to browse through the search results. However I am having problems with this, I think maybe to do with the fact I am using POST.
What is the correct method of implementing ajax style pagination on CGridView? Also how can we ensure that when the user clicks into a result and then clicks back, they are taken back to their previous page number?
Here is my SearchController:
public function actionIndex()
{
if(isset($_POST['search']))
{
$dataProvider1=new CActiveDataProvider('Product', array(
'criteria'=>array(
'condition'=>'active=1 AND prod_name LIKE :prod_name',
'params'=>array(':prod_name'=>"%{$_POST['search']}%"),
),
'pagination'=>array(
'pageSize'=>10,
),
));
$dataProvider2=new CActiveDataProvider('Event', array(
'criteria'=>array(
'condition'=>'published=1 AND title LIKE :title',
'params'=>array(':title'=>"%{$_POST['search']}%"),
),
'pagination'=>array(
'pageSize'=>10,
),
));
$dataProvider3=new CActiveDataProvider('News', array(
'criteria'=>array(
'condition'=>'published=1 AND title LIKE :title',
'params'=>array(':title'=>"%{$_POST['search']}%"),
),
'pagination'=>array(
'pageSize'=>10,
),
));
$this->render('index', array(
'dataProvider1'=>$dataProvider1,
'dataProvider2'=>$dataProvider2,
'dataProvider3'=>$dataProvider3,
));
}
}
And my view (views/search/index.php):
<div id="product-categories">
<h1>Products</h1>
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider1,
'itemView'=>'_view_products',
)); ?>
</div>