Welcome Guest, Not a member yet? Register   Sign In
page_view for pagination page function, need to know how to display appropriate results based on segment
#1

[eluser]Brad Morse[/eluser]
I created pagination links on my index function within the blog controller.

I set the base URL to: site.com/blog/page/, so the URL's will be site.com/blog/page/1, page/2, page/3, etc...

Code:
function index() {

    $data['title'] = "My Blog Title";
    $data['heading'] = "My Blog Heading";
    //$data['query'] = $this->db->get('entries');
    
    $this->db->select('*');
    $this->db->from('entries');
    $this->db->join('authors', 'authors.id = entries.id', 'inner');
    //$this->db->join('user as user1', 'entries.author_id = authors.id');
    $data['query'] = $this->db->get();
    
    $config['base_url'] = 'http://site.com/test/page/';
    $config['uri_segment'] = 3;
    $config['total_rows'] = '200';
    $config['per_page'] = '2';

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

    echo $this->pagination->create_links();
    
    $this->load->view('blog_view', $data);
}

What I need to figure out is what my page function would look like.

Code:
function page() {
    
    $data['title'] = "My Blog Title";
    $data['heading'] = "My Blog Heading";
    //$data['query'] = $this->db->get('entries');
    
    $this->db->select('*');
    $this->db->from('entries');
    $this->db->join('authors', 'authors.id = entries.id', 'inner');
    //$this->db->join('user as user1', 'entries.author_id = authors.id');
    $data['query'] = $this->db->get();
    
    $config['uri_segment'] = 2;
    $config['base_url'] = 'http://site.com/test/page/';
    $config['total_rows'] = '200';
    $config['per_page'] = '2';

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

    echo $this->pagination->create_links();
    
    $this->load->view('blog_view', $data);
}

This is just a copy from the index function. I looked thru the configs on the pagination CI page, but could not find any variables for passing whatever value segment(3) gets, which would tell the page function what page of results it is to display.

So the question is, how would I go about creating the page function to display the results that I need to display based on segment(3)
#2

[eluser]Thorpe Obazee[/eluser]
Pagination tutorial

Try this link




Theme © iAndrew 2016 - Forum software by © MyBB