public function actionViewlist($id = '', $cate = '') { $data['root'] = Category::model()->findByPk($id); $this->title = $data['root']->title; if ($id == 34) { $cs = Yii::app()->getClientScript(); $cs->registerScript('Audio', '$(".vlum").click(function(e){playAudio($(this),$(this).attr("alt"));})', CClientScript::POS_END); $data['danhngon'] = Danhngon::model()->findAll(array("condition" => "state = 1", "order" => "created_date desc", "limit" => 30)); $this->render("viewlist2", $data); } else { if ($data['root']->taxonomy_id != $this->root_id) { throw new CHttpException(404, 'PAGE NOT FOUND.'); } $data['is_cate'] = 0; $data['items'] = Content::model()->findAll(array("condition" => "state = 1 and category_id = " . $id)); $data['listcat'] = Category::model()->findAll(array("condition" => "state = 1 and taxonomy_id = " . $data['root']->taxonomy_id)); if (count($data['items']) == 0) { $data['items'] = Category::model()->findAll(array("condition" => "state = 1 and parent = " . $id)); $data['is_cate'] = 1; } $data['cate'] = null; if ($cate != '') { $data['cate'] = Category::model()->findByPk($cate); } $this->render("viewlist", $data); } }
public function run() { parent::run(); $cs = Yii::app()->getClientScript(); $cs->registerScript('Audio', '$(".vlum").click(function(e){playAudio($(this),$(this).attr("alt"));})', CClientScript::POS_END); $data['danhngon'] = Danhngon::model()->findAll(array("condition" => "state = 1", "order" => "created_date desc", "limit" => 10)); $this->render('danhngon', $data); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = Danhngon::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }