/** * Displays post by category * @param [int] $categoryId [description category id] * @param [string] $slug [description slug seo] * @return [array] [list all object ] */ public function categoryAction($categoryId, $slug) { $category = Categories::findFirstById($categoryId); if (!$category) { $this->flashSession->notice('The category doesn\'t exist'); return $this->response->redirect(); } $numberPage = 1; if ($this->request->getQuery("page", "int")) { $numberPage = $this->request->getQuery("page", "int"); } $posts = Posts::find("categoriesId = '{$categoryId}'"); $paginator = new Paginator(array("data" => $posts, "limit" => 10, "page" => $numberPage)); $this->view->page = $paginator->getPaginate(); $this->view->categories = Categories::find(); }
public function deleteAction($id) { $categories = Categories::findFirstById($id); if (!$categories) { $this->flash->error(_("Ucategories was not found")); return $this->dispatcher->forward(array('action' => 'index')); } if (!$categories->delete()) { $this->flash->error($categories->getMessages()); } else { $this->flash->success(_("Categories was deleted")); } return $this->dispatcher->forward(array('action' => 'index')); }