public function renderDefault($idkat = 0, $page = 1) { $this->template->paginator = new Nette\Utils\Paginator(); $this->template->paginator->setItemsPerPage(9); // počet položek na stránce $this->template->paginator->setPage($page); if ($idkat == 0) { $this->template->paginator->setItemCount($this->database->findAll('inzeraty')->where('NOW() <= expire')->count("*")); $this->template->inzeraty = $this->database->findAll('inzeraty')->where('NOW() <= expire')->order('added DESC')->limit($this->template->paginator->getLength(), $this->template->paginator->getOffset()); } elseif ($idkat == 10) { $this->template->paginator->setItemCount($this->database->findAll('inzeraty')->where('NOW() <= expire AND id_user = ?', $this->user->id)->count("*")); $this->template->inzeraty = $this->database->findAll('inzeraty')->where('NOW() <= expire AND id_user = ?', $this->user->id)->order('added DESC')->limit($this->template->paginator->getLength(), $this->template->paginator->getOffset()); } else { $this->template->paginator->setItemCount($this->database->findAll('inzeraty')->where('NOW() <= expire AND id_kategorie = ?', $idkat)->count("*")); $this->template->inzeraty = $this->database->findAll('inzeraty')->where('NOW() <= expire AND id_kategorie = ?', $idkat)->order('added DESC')->limit($this->template->paginator->getLength(), $this->template->paginator->getOffset()); } $this->template->kategorie = $this->database->findAll('kategorie'); $this->template->vybranakat = $this->database->findById('kategorie', $idkat); $this->template->dbUser = $this->database->findById('user', 1); // vytvorim objekt pomoci me modelove tridy v app/model $mujZooObjekt = new Model\TestModelClass(); // do promenne pro template nactu pole zvirat $this->template->zviratka = $mujZooObjekt->vratPole(); if ($this->template->vybranakat == null and $idkat == 10) { $this->template->vybranakat = (object) array('nazev' => 'Moje inzeráty', 'id' => $idkat); } $this->template->pictures = $this->database->findAll('image'); }
public function renderUkazkovaMetoda() { // vytvorim objekt, pomoci me modelove tridy v app/model $komentareVsechny = new Model\TestModelClass(); // do promenne pro template nactu pole zvirat $this->template->komentare = $komentareVsechny->vratKomentare(); $this->template->datakomentaru = $komentareVsechny->vratDataKomentaru(); }