Hello everyone! I’ve been using Yii for some time and have to say that every day I discover something exciting and new! Very nice framework!
However I have come to simple problem, and wanted to ask Yii people to help me.
In my controller, I have code that loads dataprovider from database.
In my view I use that dataprovider to render zii.widgets.CListView.
But then, I get from javascript a variable (site visitor location), and want to get that variable back to controller (doesn’t have to be the same controller mentioned above), so it can update the dataprovider (eg. search items in database with same or similar location string) and get updated/new dataprovider back to view page so it can render another CListView.
I’m stuck, how can I do this?
Here is my code for siteController.php
public function actionIndex()
{
$dataProvider=new CActiveDataProvider('Project', array(
'criteria'=>array(
'condition'=>'project_status = 0',
),
'pagination'=>array(
'pageSize' => 8,
),
));
$this->render('index',array('dataProvider'=>$dataProvider));
}
So in my view, I use that dataprovider, and also get the location variable from google:
CityName = google.loader.ClientLocation.address.city;
Now I want to write something like this:
CHtml::ajax(CODE HERE)
So I can return without refreshing to another siteControler function and do this:
public function actionIndexLocation($locationName)
{
$dataProvider=new CActiveDataProvider('Project', array(
'criteria'=>array(
'condition'=>'project_status = 0 AND location.location_name LIKE ' . '%' . $locationName . '%',
'limit' => 4,
),
));
$this->renderPartial('indexLocation', array('dataProvider'=>$dataProvider));
}
and get new dataprovider to render another CListView from the same view.
Can you please give me some help?