public function taggedAction($tag) { $tag = $this->filter->sanitize($tag, "alphanum"); Phalcon_Tag::setTitle('Tagged ' . $tag); $category = Categories::findFirst("name='{$tag}'"); if ($category == false) { return $this->_forward('index/index'); } $news = array(); $newsCategories = NewsCategories::find(array("categories_id='" . $category->id . "'")); foreach ($newsCategories as $newCategory) { $news[] = $newCategory->getNews(); } $this->view->setVar("activeYear", 0); $this->view->setVar("tag", $tag); $this->view->setVar("news", $news); $this->view->setVar("years", News::count(array('group' => 'year'))); }
public function taggedAction($tag) { $tag = $this->filter->sanitize($tag, "alphanum"); $exists = $this->view->getCache()->exists($tag); if (!$exists) { Phalcon\Tag::setTitle('Tagged ' . $tag); $category = Categories::findFirst("name='{$tag}'"); if ($category == false) { return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index')); } $news = array(); $newsCategories = NewsCategories::find(array("categories_id='" . $category->id . "'")); foreach ($newsCategories as $newCategory) { $news[] = $newCategory->getNews(); } $this->view->setVar("activeYear", 0); $this->view->setVar("tag", $tag); $this->view->setVar("news", $news); $this->view->setVar("years", News::count(array('group' => 'year'))); } $this->view->cache(array("lifetime" => 86400, "key" => $tag)); }