public function action_index() { //if they want to see a single post $seotitle = $this->request->param('seotitle', NULL); if ($seotitle !== NULL) { return $this->action_view($seotitle); } //template header $this->template->title = __('Blog'); $this->template->meta_description = __('Blog'); $posts = new Model_Post(); $posts->where('status', '=', 1); $res_count = $posts->count_all(); // check if there are some post if ($res_count > 0) { // pagination module $pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $res_count, 'items_per_page' => core::config('general.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action())); Breadcrumbs::add(Breadcrumb::factory()->set_title(__("Page ") . $pagination->current_page)); //we sort all ads with few parameters $posts = $posts->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); } else { $posts = NULL; $pagination = NULL; } $this->template->bind('content', $content); $this->template->content = View::factory('pages/blog/listing', array('posts' => $posts, 'pagination' => $pagination, 'user' => Auth::instance()->get_user())); }
/** * * Loads a basic list info * @param string $view template to render */ public function action_index($view = NULL) { $this->template->title = __($this->_orm_model); $this->template->scripts['footer'][] = 'js/oc-panel/crud/index.js'; $elements = new Model_Post(); $elements->where('id_forum', 'IS', NULL); $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $elements->count_all()))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action())); $pagination->title($this->template->title); $elements = $elements->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); $pagination = $pagination->render(); if ($view === NULL) { $view = 'oc-panel/pages/blog/index'; } $this->render($view, array('elements' => $elements, 'pagination' => $pagination)); }