CodeIgniter pagination not working for get method -
i needed pagination parameters. in method i've written following code follows.
public function index($offset = 0) { $data['title_for_layout'] = 'apartment advertisement - search'; // pagination config $this->load->library('pagination'); $pagination['enable_query_strings'] = true; $pagination['page_query_string'] = true; $pagination['allow_get_array'] = true; $pagination['first_url'] = base_url('search'); $pagination['base_url'] = $config['first_url']; $pagination['total_rows'] = $this->aa_movies->no_of_search_movies(); $data['no_of_results'] = $pagination['total_rows']; $pagination['use_page_numbers'] = true; $pagination['per_page'] = 20; // initialize pagination $this->pagination->initialize($pagination); // offset $offset = 20 * $offset; // apartments $data['apartments'] = $this->aa_movies->search_movies($this->input->get('keyword'), $this->input->get('city'), $this->input->get('locations'), $offset); $this->load->view($this->config->item('index_search_view'), $data); }
in view
<?php echo form_open(base_url('search'), array('method' => 'get'); ?> <?php echo $this->pagination->create_links(); ?> <?php echo form_close(); ?>
so pagination url looks like
http://localhost/reelstubs/search/1
but wanted in pagination url follows
http://localhost/reelstubs/search?keyword=complex&city=bangalore&page=1
even tried changing pagination base_url including $_server['request_uri']. url looks like
http://localhost/reelstubs/search?keyword=complex&city=bangalore/1
so i'm not getting page no using $this->uri->segment();
please me on this. been 2 days i've wasted on this. work more appreciated.
you can add filtering string (keyword , city) in hidden inputs , values using $this->input->get('name')
or can send necessary values in segment , using $this->uri->segment();
http://localhost/search/method(func)/complex/bangalore/1
$keyword = $this->uri->segment('3');
$city = $this->uri->segment('4');
$page = $this->uri->segment('5');
Comments
Post a Comment