Guys,
First i am telling about my project,
I develop a project where i add a FAQ page, the questions and associative answers. now i want, when i hover my mouse to a question, with jquery, the associative answer will be popup. (questions and answers are generated from database).
Now, in my controller i added these:
public function actionIndex()
{
$criteria=new CDbCriteria(array('condition'=>'status='.Faq::STATUS_ACTIVE,));
$dataProvider=new CActiveDataProvider('Faq',
array(
'criteria'=>$criteria,
'pagination'=>array(
'pageSize'=>8,),
));
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
}
public function loadModel()
{
if($this->_model===null)
{
if(isset($_GET['id']))
{
//$this->_model=Faq::model()->findbyPk($_GET['id']);
if(Yii::app()->user->isGuest)
$condition='status='.Faq::STATUS_ACTIVE.' OR status='.Faq::STATUS_INACTIVE;
else
$condition='';
$this->_model=Faq::model()->findByPk($_GET['id'], $condition);
}
if($this->_model===null)
throw new CHttpException(404,'The requested page does not exist.');
}
return $this->_model;
}
And in my view:
index.php:
<?php
$this->widget(‘zii.widgets.CListView’, array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'summaryText' => '',
));
?>
and,
_view.php:
<?php echo CHtml::encode($data->getAttributeLabel(‘ques’)); ?>:
<?php echo CHtml::encode($data->ques); ?>
<?php echo CHtml::encode($data->getAttributeLabel(‘ans’)); ?>:
<?php echo CHtml::encode($data->ans); ?>
Here, all data are shown, please if i bother you with my codes forgive me.
But i really need helps. Thanks<tanim>