Exemplo n.º 1
0
 public function actionIndex($slug)
 {
     $page = PageService::findBySlug($slug);
     if (isset($page)) {
         // Find Template
         $content = $page->content;
         $template = $content->template;
         // Page using Template
         if (isset($template)) {
             $layout = $template->layout;
             $view = $template->viewPath . "/{$template->frontendView}";
             $this->layout = "//{$layout}";
             // Render using Template
             if (isset($layout) && isset($view)) {
                 return $this->render($view, ['page' => $page, 'author' => $page->createdBy, 'content' => $content, 'banner' => $content->banner]);
             } else {
                 return $this->render('index', [CoreGlobal::FLASH_GENERIC => Yii::$app->cmgCmsMessage->getMessage(CmsGlobal::ERROR_NO_VIEW)]);
             }
         } else {
             return $this->redirect('site/' . $page->slug);
         }
     }
     // Page not found
     throw new NotFoundHttpException(Yii::$app->cmgCoreMessage->getMessage(CoreGlobal::ERROR_NOT_FOUND));
 }
Exemplo n.º 2
0
 /**
  * It returns page full content to be used in page blocks on other pages.
  * @return string - page content
  */
 public static function getPageContent($config = [])
 {
     if (isset($config['slug'])) {
         $slug = $config['slug'];
         $page = PageService::findBySlug($slug);
     }
     if (isset($config['page'])) {
         $page = $config['page'];
     }
     if (isset($page)) {
         $content = $page->content;
         $content = $content->content;
         $content .= "<div class='page-content'>{$content}</div>";
         return $content;
     }
     return '';
 }