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/>';