示例#1
0
 public function process()
 {
     $categoryName = $this->getParam('name');
     $categoryModel = new Categories();
     $category = $categoryModel->filter('name', $categoryName)->getOne();
     if (!is_null($category)) {
         return $this->getViewDispatcher()->renderView(new views\news\NewsCategory(), ['category' => $category]);
     } else {
         throw new \Exception('Category ' . $categoryName . ' was not found');
     }
 }
示例#2
0
 public function prepare()
 {
     $this->template = APP_VIEWS_ROOT . '/templates/partials/tags_menu.php';
     $this->setTemplateVariable('block_name', 'categories-menu');
     $categoriesModel = new Categories();
     //    $newsModel = new news();
     //    var_dump($newsModel->get());
     $items = [];
     foreach ($categoriesModel->get() as $category) {
         $items['category' . $category['name']] = ['id' => $category['id'], 'text' => $category['title'], 'class' => 'rat-' . round($category['rating'] / 20), 'link' => '/category/' . $category['name']];
     }
     $this->setTemplateVariable('menu_links', $items);
     $this->setTemplateVariable('active_link', $this->activePage);
 }