public function indexAction() { $this->view->headTitle('Flux', 'PREPEND'); $flash = $this->_helper->FlashMessenger->getMessages(); if (!empty($flash[0])) { $this->view->eViasMessage = $flash[0]; } $activeId = 0; if ($this->_hasParam('id')) { $activeId = $this->_getParam('id'); } $publishedEntries = array(); $activeEntry = null; try { $publishedEntries = eVias_Blog_Article::loadAllPublished(); if (empty($publishedEntries)) { throw new eVias_Exception('no entries in evias_blog_article.'); } $activeEntry = $activeId == 0 ? $publishedEntries[0] : eVias_Blog_Article::loadById($activeId); } catch (eVias_Exception $e) { if (isset($publishedEntries) && false === $publishedEntries) { $publishedEntries = array(); } $activeEntry = new eVias_Blog_Article(); } // simple render of action $countPublished = count($publishedEntries); $this->_helper->layout()->setLayout('blog'); $this->view->article = $activeEntry; $this->view->articleTitle = $activeEntry->titre; }
private function _getBlogLatest() { if (empty($this->_articles)) { $articles = eVias_Blog_Article::loadAllPublished(); $this->_articles = $articles; } $html = ""; if (!empty($this->_articles)) { $html .= "<ul>"; for ($ix = 0, $cntArticles = count($this->_articles); $ix < 3 && $ix < $cntArticles; $ix++) { $articleTitle = $this->_articles[$ix]->titre; $articleLink = "/blog/index/show-full-article/?article_id=" . $this->_articles[$ix]->article_id; $html .= "\n <li class='article'>\n <a href='{$articleLink}'>\n - {$articleTitle}\n </a>\n </li>\n "; } $html .= "</ul>"; } return $html; }