public function action_index() { $cat = new Model_Category(); $list_cat = $cat->find_all(); // get all to print at sidebar view $loc = new Model_Location(); $list_loc = $loc->find_all(); // get all to print at sidebar view $user = Auth::instance()->get_user(); $ads = new Model_Ad(); Controller::$full_width = TRUE; $my_adverts = $ads->where('id_user', '=', $user->id_user); $res_count = $my_adverts->count_all(); if ($res_count > 0) { $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $res_count, 'items_per_page' => core::config('advertisement.advertisements_per_page')))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action())); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('My ads'))->set_url(Route::url('oc-panel', array('controller' => 'myads', 'action' => 'index')))); Breadcrumbs::add(Breadcrumb::factory()->set_title(sprintf(__("Page %d"), $pagination->current_page))); $ads = $my_adverts->order_by('published', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); $this->template->content = View::factory('oc-panel/profile/ads', array('ads' => $ads, 'pagination' => $pagination, 'category' => $list_cat, 'location' => $list_loc, 'user' => $user)); } else { $this->template->content = View::factory('oc-panel/profile/ads', array('ads' => $ads, 'pagination' => NULL, 'category' => NULL, 'location' => NULL, 'user' => $user)); } }