public function action_index() { $sort = $this->request->param('sort', 'title'); $order = $this->request->param('order', 'ASC'); //Session::instance()->delete('course_id'); $criteria = array('filters' => array('title' => $this->request->param('filter_title'), 'description' => $this->request->param('filter_description'))); $total = Model_Video::video_total($criteria); $pagination = Pagination::factory(array('total_items' => $total, 'items_per_page' => 5)); $criteria = array_merge($criteria, array('sort' => $sort, 'order' => $order, 'limit' => $pagination->items_per_page, 'offset' => $pagination->offset)); $videos = Model_Video::videos($criteria); $sorting = new Sort(array('Title' => 'title', 'Description' => 'description')); $url = 'video/index'; if ($this->request->param('filter_title')) { $url .= '/filter_title/' . $this->request->param('filter_title'); $filter = $this->request->param('filter_title'); $filter_select = 'filter_title'; } if ($this->request->param('filter_description')) { $url .= '/filter_description/' . $this->request->param('filter_description'); $filter = $this->request->param('filter_description'); $filter_select = 'filter_description'; } $sorting->set_link($url); $sorting->set_order($order); $sorting->set_sort($sort); $heading = $sorting->render(); // Render the pagination links $pagination = $pagination->render(); $links_old = array('delete' => URL::site('/video/delete/'), 'add' => URL::site('/video/add/'), 'search' => URL::site('/video/search/')); $table = array('data' => $videos); $filter_title = $this->request->param('filter_title'); $filter_description = $this->request->param('filter_description'); $filter_url = URL::site('video/index'); $success = Session::instance()->get('success'); Session::instance()->delete('success'); $view = View::factory('video/list')->bind('table', $table)->bind('count', $total)->bind('links_old', $links_old)->bind('pagination', $pagination)->bind('filter', $filter)->bind('filter_select', $filter_select)->bind('filter_url', $filter_url)->bind('success', $success); $this->content = $view; }