public function index($offset=0) { // Header $data['page_title'] = "Index"; $this->load->view("header", $data); // Get recipe data $recipe_list = new Recipe(); $total_rows = $recipe_list->count(); $recipe_list->order_by('title'); $data["recipes"] = $recipe_list->get(5, $offset)->all; // Pagination $config['base_url'] = site_url("recipes"); $config['total_rows'] = $total_rows; $config['per_page'] = '5'; $config['uri_segment'] = 2; $this->pagination->initialize($config); $data['pagination'] = $this->pagination->create_links(); // Body of page $this->load->view("recipes/index", $data); // Footer $this->load->view('footer'); }
public static function index() { $params = $_GET; $page_size = 5; $recipes_count = Recipe::count(); $pages = ceil($recipes_count / $page_size); if (isset($params['page'])) { self::make_paged_index($params, $pages, $page_size); } else { self::without_page_param_show_home(); } }