예제 #1
0
 public function prepare()
 {
     parent::prepare();
     $this->template = APP_VIEWS_ROOT . '/templates/pages/index.php';
     $newsModel = new News();
     $news = $newsModel->limit(5)->order('published', 'desc')->get();
     $this->setTemplateVariable('news_items', $news);
 }
예제 #2
0
 public function process()
 {
     $newsId = $this->getParam('id');
     $news_model = new News();
     $news = $news_model->filter('id', $newsId)->getOne();
     if ($news) {
         return $this->getViewDispatcher()->renderView(new views\news\NewsItem(), ['pageTitle' => 'Последние новости никарагуа', 'news' => $news]);
     } else {
         throw new \Exception('News ' . $newsId . ' was not found');
     }
 }
예제 #3
0
 public function prepare()
 {
     parent::prepare();
     $this->template = APP_VIEWS_ROOT . '/templates/pages/news.php';
     $category = $this->category;
     $newsModel = new News();
     $news = $newsModel->limit(10)->get();
     if (is_null($category)) {
         throw new \Exception('Category was not set');
     }
     $this->setTemplateVariable('page_title', $category['title']);
     $this->setTemplateVariable('news_items', $news);
 }