public function lastNews($limit = 5) { $publicationHelper = new PublicationHelper(); $fields = $publicationHelper->translateFieldsSubQuery(); $columns = ['p.*', 't_slug' => 't.slug']; $columns = array_merge($columns, $fields); $qb = $this->modelsManager->createBuilder()->columns($columns)->addFrom('Publication\\Model\\Publication', 'p')->leftJoin('Publication\\Model\\Type', null, 't')->andWhere('t.slug = :type:', ['type' => 'news'])->andWhere('p.date <= NOW()')->orderBy('p.date DESC')->limit($limit); $entries = $qb->getQuery()->execute(); $this->widgetPartial('widget/last-news', ['entries' => $entries]); }
public function publicationAction() { $slug = $this->dispatcher->getParam('slug', 'string'); $type = $this->dispatcher->getParam('type', 'string'); $publicationHelper = new PublicationHelper(); $publicationResult = $publicationHelper->publicationBySlug($slug); if (!$publicationResult) { throw new Exception("Publication '{$slug}.html' not found"); } if ($publicationResult->p->getTypeSlug() != $type) { throw new Exception("Publication type <> {$type}"); } $this->helper->title()->append($publicationResult->meta_title); $this->helper->meta()->set('description', $publicationResult->meta_description); $this->helper->meta()->set('keywords', $publicationResult->meta_keywords); $this->helper->menu->setActive($type); $this->view->publicationResult = $publicationResult; }