/**
  * 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 = CmsNode::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #2
0
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['id'])) {
             $this->_model = CmsNode::model()->findbyPk($_GET['id']);
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Example #3
0
 /**
  * Runs the widget.
  */
 public function run()
 {
     $model = CmsNode::model()->with('cms')->findByAttributes(array('cms_type' => 2, 'name' => $this->name));
     $this->render('block', array('model' => $model, 'content' => $model->cms->body));
 }