public function render() { $template = $this->template; $blog = $this->database->table("pages")->where(array("date_published <= ?" => date('Y-m-d H:i:s'), "pages_types_id" => 2))->order("date_created DESC"); $paginator = new \Nette\Utils\Paginator(); $paginator->setItemCount($blog->count("*")); $paginator->setItemsPerPage(20); $paginator->setPage($this->presenter->getParameter("page")); $template->blog = $blog->limit($paginator->getLength(), $paginator->getOffset()); $template->paginator = $paginator; $template->args = $this->getParameters(); $template->setFile(__DIR__ . '/BlogListControl.latte'); $template->render(); }
<div class="page-header"> <h1><i class="fa fa-list"></i> Logs <a class="btn btn-default" href='/new'><i class="fa fa-plus"></i> Add a new log</a> </h1> </div> <?php $paginator = new Nette\Utils\Paginator(); $paginator->setItemCount(11); // the total number of records (e.g., a number of products) $paginator->setItemsPerPage(5); // the number of records on page $paginator->setPage(2); // the number of the current page (numbered from one) //$result = dibi::select('*')->from('logs_new')->orderBy('time DESC')->limit($paginator->getLength(),',', $paginator->getOffset()); //echo count($result); $logs = dibi::select('*')->from('logs_new')->orderBy('time DESC')->limit(10); //echo count($logs); if (!isset($_GET['station'])) { // .. } else { $limit = array('station = %s', $_GET['station']); $logs->where($limit[0], $limit[1]); echo 'Showing only ' . htmlspecialchars($_GET['station']); } $logs = $logs->fetchAll(); echo '<table class="table table-hover table-condensed">'; echo '<thead><tr><th>Time</th><th>Station</th><th>Frequency</th><th>Call #</th><th>Call Id</th><th>Group Count</th><th>Reporter</th></tr></thead><tbody>'; foreach ($logs as $row) { echo '<tr>'; //if($row->time == null) {echo 'null time';} //if(strtotime($row->time)=='0000-00-00 00:00:00'){echo 'null date';} //echo strtotime($row->time) .'<br/>';
$breadcrumbs = [['title' => 'People']]; $people = collection('People')->find()->sort(['Order' => 1])->toArray(); $latte->render('templates/people/people.latte', ['breadcrumbs' => $breadcrumbs, 'people' => $people]); }); $app->get('/people/:slug', function ($slug) use($app, $latte) { $person = collection('People')->findOne(['Name_slug' => $slug]); $breadcrumbs = [['title' => 'People', 'link' => '/people'], ['title' => $person['Name']]]; $latte->render('templates/people/person.latte', ['breadcrumbs' => $breadcrumbs, 'person' => $person]); }); $app->get('/news', function () use($app, $latte) { // prepare breadcrumbs $breadcrumbs = [['title' => 'News archive']]; $newsCount = cockpit('collections:count', 'News'); $pageParam = $app->request()->get('page'); $currentPage = $pageParam ? $pageParam : 1; $paginator = new \Nette\Utils\Paginator(); $paginator->setItemCount($newsCount); $paginator->setItemsPerPage(6); $paginator->setPage($currentPage); $limit = $paginator->getItemsPerPage(); // per page $offset = $paginator->getOffset(); $news = collection('News')->find()->limit($limit)->skip($offset)->sort(['created' => -1])->toArray(); $latte->render('templates/news/news.latte', ['breadcrumbs' => $breadcrumbs, 'paginator' => $paginator, 'news' => $news]); }); $app->get('/news/:slug', function ($slug) use($latte) { $entry = collection('News')->findOne(['Title_slug' => $slug]); if ($entry == null) { $latte->render('templates/error.latte'); return; }