Example #1
0
 public function renderDefault()
 {
     $idMedia = $this->template->settings['categories:id:media'];
     if ($this->getParameter('id')) {
         $arr = array("pages_types_id" => $this->template->pageId, "pages_id" => $this->getParameter('id'));
     } else {
         if ($this->getParameter("type") == 6) {
             $pageId = 4;
         } else {
             $pageId = 6;
         }
         $arr = array("pages_types_id" => $this->template->pageId, "pages_id" => $pageId);
     }
     $this->template->media = $this->database->table("pages")->where($arr);
     if ($this->getParameter("id")) {
         $idN = $this->getParameter('id');
     } else {
         $idN = $idMedia;
     }
     $this->template->idN = $idN;
     $mediaDb = $this->database->table("media")->where(array('media.pages_id' => $idN, 'pages.pages_types_id' => $this->template->pageId))->order("name");
     $paginator = new \Nette\Utils\Paginator();
     $paginator->setItemCount($mediaDb->count("*"));
     $paginator->setItemsPerPage(10);
     $paginator->setPage($this->getParameter("page"));
     $this->template->args = $this->getParameters();
     $this->template->documents = $mediaDb;
     $this->template->mediaType = $this->getParameter('cat');
     $this->template->paginator = $paginator;
     $this->template->productsArr = $mediaDb->limit($paginator->getLength(), $paginator->getOffset());
     if ($this->getParameter("id")) {
         $category = new Model\Category($this->database);
         $this->template->breadcrumbs = $category->getPageBreadcrumb($this->getParameter("id"));
     }
     $this->template->mediatype = $this->context->httpRequest->getCookie('mediatype');
 }