• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Query String Not Staying In Pagination URL

#1
On my codeigniter pagination I am trying to get my page size query string in url to stay when I click on my pagination button links.

Pagesize is created when I select a from a dropdown menu.

When a page size is selected creates url like so

http://localhost/project/example/?&pagesize=10

But when I click on my pagination button like lets say my second link it makes url like but does not show pagesize.

http://localhost/project/example?per_page=10

When I click on pagination button I would like it to look like

http://localhost/project/example?per_page=10&pagesize=10

Question If page size is selected how can I make it show when I click on a pagination link after perpage

Any Suggestion


PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Example extends MX_Controller {

 
  public function __construct() {
 
       parent:: __construct();
 
       $this->load->library("pagination");
 
  }

 
  public function index() {
    
$data['title'] = "Example Codeigniter Pagination";

    
$get_sort $this->input->get('sort');

 
       if (isset($get_sort)) {
    
$sort $get_sort;
    } else {
    
$sort 'example_id';
    }

    
$get_order $this->input->get('order');

    if (isset(
$get_order)) {
    
$order $get_order;
    } else {
    
$order 'asc';
    }

    
$get_pagesize $this->input->get('pagesize');

    if (isset(
$get_pagesize)) {
    
$pagesize $get_pagesize;
    } else {
    
$pagesize 10;
    }

    
$data['limits'] = array();

    
$limits array_unique(array(102030405060708090100));

    
sort($limits);

    foreach(
$limits as $value) {
    
$data['limits'][] = array(
    
'text' => $value,
    
'value' => $value,
    
'href'  => base_url() .'example' .'/?&pagesize='$value
    
);
    }

 
       $config["base_url"] = base_url('example');
 
       $config["total_rows"] = $this->record_count();
 
       $config["per_page"] = $pagesize;
 
       $config['page_query_string'] = TRUE;

 
       $config['full_tag_open'] = '<ul class="pagination">';
    
$config['full_tag_close'] = '</ul>';
    
$config['first_link'] = false;
    
$config['last_link'] = false;
    
$config['first_tag_open'] = '<li>';
    
$config['first_tag_close'] = '</li>';
    
$config['prev_link'] = '&laquo';
    
$config['prev_tag_open'] = '<li class="prev">';
    
$config['prev_tag_close'] = '</li>';
    
$config['next_link'] = '&raquo';
    
$config['next_tag_open'] = '<li>';
    
$config['next_tag_close'] = '</li>';
    
$config['last_tag_open'] = '<li>';
    
$config['last_tag_close'] = '</li>';
    
$config['cur_tag_open'] = '<li class="active"><a href="#">';
    
$config['cur_tag_close'] = '</a></li>';
    
$config['num_tag_open'] = '<li>';
    
$config['num_tag_close'] = '</li>';

 
       $this->pagination->initialize($config);

 
       $offset = ($this->input->get('per_page')) ? $this->input->get('per_page') : 0;

 
       $data['results'] = array();
 
       $data["results"] = $this->get_examples($config["per_page"], $offset);
 
       $data["links"] = $this->pagination->create_links();

 
       $url '';

 
       if ($order == 'asc') {
    
$url .= '&order=desc';
    } else {
    
$url .= '&order=asc';
    }

    
$data['example_id'] = base_url('example') . '/?&sort=example_id' .$url;
    
$data['example_name'] = base_url('example') . '/?&sort=example_name' .$url;
    
$data['example_date_added'] = base_url('example') . '/?&sort=example_date_added' .$url;

    
$url '';

    if (isset(
$get_sort)) {
    
$url .= '&sort=' $get_sort;
    }

    if (isset(
$get_order)) {
    
$url .= '&order=' $get_order;
    }

    
$data['pagesize'] = $pagesize;
    
$data['sort'] = $sort;
    
$data['order'] = $order;

    
$this->load->view('example_view'$data);
 
  }


Routes


PHP Code:
$route['example'] = "example/index";
$route['example/(:any)'] = "example/index/$1";
$route['example/(:any)/(:any)'] = "example/index/$1/$2";
$route['example/(:any)/(:any)/(:any)'] = "example/index/$1/$2/$3";
$route['example/(:any)/(:any)/(:any)/(:any)'] = "example/index/$1/$2/$3/$4"


Attached Files
.php   Example.php (Size: 3.49 KB / Downloads: 231)
.php   example_view.php (Size: 3.06 KB / Downloads: 201)
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Messages In This Thread
[Solved] Query String Not Staying In Pagination URL - by wolfgang1983 - 06-05-2015, 08:02 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.