nkhanna24
(Nkhanna24)
1
Hi
I am new in yii framework. I came across this code.
$criteria=new CDbCriteria();
if(isset($_GET['tag']))
$criteria->addSearchCondition('question.tags',$_GET['tag']);
$param = Yii::app()->request->getParam('param');
$dataProvider=new CActiveDataProvider(Question::model()->recent()->with(‘user’)->with(‘answers’));
$this->render(‘index’,array(‘dataProvider’=>$dataProvider,
'param'=>$param,
'tags'=>$tags,
'usertype'=>$usertype));
can anyone explain what getparam(‘param’) and $this->render() do?
and where this ‘param’ variable coming from?
Thankyou in advance…
perochak
(Amjad Mughal)
2
This part of code is about $_GET. it checks and gets the value for param if it is there in the query string.
this part of code render’s i.e. give the output of the code to a view.
nkhanna24
(Nkhanna24)
3
Thanks…
but where can i find ‘param’ variable. Actually this code is in actionask() in fcontroller.php.
And i have a model question.php which have attributes qid,question(text),instituteid(int).
i have to view the question in index.php.
so where the condition is specified like (where(instituteid ==5))?
perochak
(Amjad Mughal)
4
share the code so that I can tell you about it.
moreover, here param is just for demonstration.
we can have it as
CHtml::link('[age url',$this->createUrl('site/question',array('a'=>1)));
then we can get value of a in site/question action as
Yii::app()->request->getParam('a');