Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AdminModule;
- /**
- * Homepage presenter.
- */
- class HomepagePresenter extends BasePresenter
- {
- /**
- * @var \App\Components\IArticleMenuFactory
- * @inject
- */
- public $articleMenuFactory;
- /** @persistent */
- public $category;
- /**
- *
- * @return ArticleMenu
- */
- public function createComponentArticleMenu()
- {
- $control = $this->articleMenuFactory->create();
- $control['articleMenu']->onSuccess[] = function($form) {
- $this->redirect('this', array('category' => $form->values->category));
- };
- return $control;
- }
- public function renderDefault() {
- if($this->category) {
- $this->template->articles = $this->articles->getArticleByCategoryId($this->category);
- } else {
- $this->template->articles = $this->articles->fetchAll();
- }
- }
- }
- Šablona:
- {block content}
- <br /> <br />
- <div class="main"><h3>Posledních 10 příspěvků:</h3> <br />
- {control articleMenu}
- <br /> <br />
- <table class="table-article-create">
- <thead>
- <tr>
- <th>ID</th>
- <th>Název</th>
- <th>Text</th>
- <th>Autor</th>
- <th>Datum</th>
- <th>Kategorie</th>
- </tr>
- </thead>
- <tbody>
- <tr n:foreach = "$articles as $article">
- <td>{$article->id}</td>
- <td>{$article->title|striptags}</td>
- <td class="content"><a n:href='Articles:edit $article->id'>{!$article->content|substr:0,35|striptags}</a></td>
- <td>{$article->author ? $article->author:('Neznámý')}</td>
- <td>{$article->datetime|date:"d.m.y H:i"}</td>
- <td>{($category = $article->ref('categories','categories_id')) ? $category->name:('Nezařazeno')}</td>
- </tr>
- </tbody>
- </table>
- </div>
- {/block}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement