Beispiel #1
0
 /**
  * Render default view
  *
  * @param string $q
  */
 public function renderDefault($keyword, $page = 1)
 {
     // get all categories
     $categories = $this->categoryRepo->findAll();
     $this->template->categories = $categories;
     $paginator = new Nette\Utils\Paginator();
     $paginator->setItemsPerPage(self::PER_PAGE);
     // the number of records on page
     $paginator->setPage($page);
     // get products
     $products = $this->productsRepo->search($keyword, ['limit' => $paginator->getLength(), 'offset' => $paginator->getOffset()] + $this->getHttpRequest()->getQuery());
     $paginator->setItemCount($products['total']);
     // the total number of records (e.g., a number of products)
     $this->template->paginator = $paginator;
     $this->template->keyword = $keyword;
     $this->template->products = $products;
 }
 /**
  * Render default view
  *
  * @param string $categoryId
  */
 public function renderDefault($page = 1, $categoryId = null)
 {
     // get all categories
     $categories = $this->categoryRepo->findAll();
     $this->template->categories = $categories;
     $this->template->category = $categories[$categoryId];
     $paginator = new Nette\Utils\Paginator();
     $paginator->setItemsPerPage(self::PER_PAGE);
     // the number of records on page
     $paginator->setPage($page);
     // get products
     $products = $this->productsRepo->findByCategory($categoryId, ['limit' => $paginator->getLength(), 'offset' => $paginator->getOffset()] + $this->getHttpRequest()->getQuery());
     $paginator->setItemCount($products['total']);
     // the total number of records (e.g., a number of products)
     $this->template->products = $products;
     $userFilters = $this->getHttpRequest()->getQuery();
     unset($userFilters['page']);
     $this->template->userFilters = $userFilters;
     $this->template->paginator = $paginator;
 }