Welcome Guest, Not a member yet? Register   Sign In
Pagination not passing parameters as URI Segment
#1

[eluser]emelpy[/eluser]
I am trying to use pagination to show a list of news articles from my database. My URL structure is /admin/news/showlist/ where admin is a directory and showlist is a function in the news controller.

Here is the code:
Code:
function showlist()
    {
        $this->load->library('pagination');
        $this->load->model('Admin_model');
        $this->load->helper('url');
        
        $config['base_url'] = site_url('vantageadmin/news/showlist/');    
        $config['total_rows'] = $this->db->count_all('ast_news');
        $config['per_page'] = '10';
        $config['full_tag_open'] = '<p>';
        $config['full_tag_close'] = '</p>';

        $offset = substr($this->uri->segment(4), strpos($this->uri->segment(4), 'per_page=') + 9);

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

        $data['results'] = $this->Admin_model->getNewsList($config['per_page'], $offset);
        
        $this->load->library('table');
        $this->table->set_heading('ID', 'Company', 'Title', 'Content', 'Posted', 'Displayed', 'Ended', 'Weight', 'Show');        
        $this->load->view('vantageadmin/news/showlist', $data);
        
    }

My problem is that CodeIgniter does not seem to be passing the per_page variable correctly. In the documentation is says that it should default to passing it as a segment e.g. /admin/news/showlist/10 where 10 is the current offset.

This is not how it is working for me. For some reason the links codeigniter is generating with pagination->create_links() look like
/admin/news/showlist/&per_page=10. This looks kind of like it's passing it via GET but when I do a var_dump on $_GET it is empty. As you can see I hacked the per_page value out of the URL using uri->segment. This works when going from page 1 to 2 but codeigniter fails to hyperlink page 1 once I am at page 2.

Any ideas on this?


Messages In This Thread
Pagination not passing parameters as URI Segment - by El Forum - 07-16-2009, 01:13 PM
Pagination not passing parameters as URI Segment - by El Forum - 07-16-2009, 01:18 PM
Pagination not passing parameters as URI Segment - by El Forum - 07-16-2009, 01:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB