Ejemplo n.º 1
0
 public function slot($slot, $parentId = 0)
 {
     // Try to load missing content from database
     // (e.g. for alias content that is not directly assigned to page)
     if (!isset($this->contents[$parentId][$slot])) {
         $contents = CmsContent::model()->findAllByAttributes(array('parentId' => $parentId, 'slot' => $slot));
         if (count($contents)) {
             $this->contents[$parentId][$slot] = $contents;
         }
     }
     // Run widget for each content that is assigned to current slot
     // and has current content as a parent
     if (isset($this->contents[$parentId][$slot])) {
         if ($this->adminMode) {
             echo '<div class="cms-slot">';
         }
         foreach ($this->contents[$parentId][$slot] as $content) {
             if ($content->module != '' && $content->action != '') {
                 $this->forward($content->module . '/frontend/' . $content->action);
             } else {
                 echo $this->runWidget($content);
             }
         }
         if ($this->adminMode) {
             echo '</div>';
         }
     }
 }
Ejemplo n.º 2
0
 public function actionDeleteblock()
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $model = $this->loadModel();
         $cms = CmsContent::model()->findByAttributes(array('nodeId' => $model->id));
         $model->delete();
         $cms->delete();
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_POST['ajax'])) {
             $this->redirect(array('/cms/admin/blocks'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
Ejemplo n.º 3
0
 public function run()
 {
     $aliasContent = CmsContent::model()->findByPk($this->content->data);
     Yii::app()->controller->runWidget($aliasContent);
 }