public function actionAll() { $items = News::findAll(); if ($items == false) { header("HTTP/1.0 404 Not Found"); throw new E404Exception('News cannot be found'); } $view = new View(); $view->assign('items', $items); $template = 'news/news_view.php'; $view->display($template); }
protected function actionIndex() { $news = \App\Models\News::findAll(); $dataTable = new \App\AdminDataTable($news, [function ($article) { return $article->id; }, function ($article) { return $article->title; }, function ($article) { return $article->author->name; }]); $this->view->news = $dataTable->render(); $this->view->display(__DIR__ . '/../templates/admin/table.php'); }
public function actionAllShow() { $this->view->items = Model::findAll(); $this->view->display('all'); //Пример работы шаблонизатора Twig /*$items = Model::findAll(); $isAdmin = App::isAdmin(); $login = $_SESSION['user']['login']; echo $this->twig->render('all.html', array ( 'items' => $items, 'login' => $login, 'isAdmin' => $isAdmin ));*/ }
protected function actionIndex() { $lastNews = \App\Models\News::findAll(); $dataTable = new AdminDataTable($lastNews, function ($m) { return $m->id; }, function ($m) { return $m->date; }, function ($m) { return $m->title; }, function ($m) { return $m->author->name; }); $this->view->display('indexTable.php', ['data' => $dataTable->render()]); }
<?php use App\Models\News; require __DIR__ . '/autoload.php'; $news = News::findAll(); include __DIR__ . '/App/Views/Admin/all.php';
<?php use App\Models\User; use App\Models\News; use App\Config; include 'autoload.php'; include 'Assets/backend/head.php'; if (!empty($_POST)) { $news = new News(); $news->title = $_POST['title']; $news->text = $_POST['text']; $news->date = '2016-02-19'; $news->save(); } $articles = News::findAll(); foreach ($articles as $news) { echo '<tr>'; echo '<td>' . $news->id . '</td>'; echo '<td>' . $news->title . '</td>'; echo '<td>' . $news->text . '</td>'; echo '<td><a href="edit.php?id=' . $news->id . '">Редактировать</a></td>'; } include 'Assets/backend/bottom.php';
/** * Метод вывода всех новостей * */ protected function actionAll() { $this->view->title = 'Урок 4 - Новости'; $this->view->news = NewsModel::findAll(); $this->view->display(__DIR__ . '/../templates/news/index.html'); }
/** * Метод вывода всех новостей * */ protected function actionAll() { $news = NewsModel::findAll(); $this->view->render('/admin/all.html', ['news' => $news]); }
/** * Метод вывода всех новостей * */ protected function actionAll() { $this->view->news = NewsModel::findAll(); $this->view->display(__DIR__ . '/../templates/admin/index.html'); }
/** * Метод вывода всех новостей * */ protected function actionAll() { $news = NewsModel::findAll(); $this->view->render('/news/index.html', ['news' => $news, 'resource' => \PHP_Timer::resourceUsage()]); }
/** * Действие для вывода всех новостей */ protected function actionIndex() { $this->view->news = \App\Models\News::findAll(); $this->view->display(__DIR__ . '/../Templates/News/All.php'); }
<?php /** * Тестирование реализации интерфейса ArrayAccess, * для его корректной работы пришлось отключить * закомментировать использование трейта MagicFunc!!! */ require_once __DIR__ . '/../../autoload.php'; $view = new \App\View(); $view->title = 'ура'; $view->green = 'зеленый'; $view->news = \App\Models\News::findAll(); foreach ($view as $prop => $value) { echo $prop . ' = ' . $value . '<br>'; } echo '<hr>';
protected function actionIndex() { $this->view->title .= ' Список новостей.'; $this->view->articles = \App\Models\News::findAll(); $this->view->display(__DIR__ . '/../Views/admin_main.php'); }
protected function actionIndex() { $this->view->title = 'Мой крутой сайт!'; $this->view->news = \App\Models\News::findAll(); $this->view->display(__DIR__ . '/../templates/index.php'); }
protected function actionIndex() { $this->view->title .= ' Новости.'; $this->view->articles = \App\Models\News::findAll(); $this->view->display(__DIR__ . '/../Views/index.php'); }