Welcome Guest, Not a member yet? Register   Sign In
Pagination
#1

[eluser]georgerobbo[/eluser]
I'm having trouble using Pagination. CodeIgniter creates the links but it doesn't like to limit the results per page.

Reference: function all()
Code:
<?php

class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();    
    }
    
    function index()
    {
        $data['title'] = "Home";
        
        $this->load->model('Category');
        
        $data['category'] = $this->Category->list_category();
        $data['random'] = $this->Post->get_random_single();
        $data['new'] = $this->Post->latest_submissions();    
        
        foreach ($data['random'] as $a): $id = $a['ID']; endforeach;
        
        $data['tag'] = $this->Post->get_tags($id);

        $this->load->view('meta', $data);
        $this->load->view('header', $data);
        $this->load->view('home', $data);
    }
    
    function single()
    {
        $permalink = $this->uri->segment(2);
        $data['current'] = $this->Post->the_post($permalink);
    
        foreach ($data['current'] as $a):
        $id = $a['ID'];
        $count = $a['views'];
        $data['title'] = $a['title'];
        endforeach;
        
        if(isset($id)) {
        
        $data['tag'] = $this->Post->get_tags($id);
        $data['count'] = $this->Post->count_view($id, $count);
        
        }
        
        $this->load->view('meta', $data);
        $this->load->view('header', $data);
        $this->load->view('single', $data);
    }
    
    function all()
    {
        $data['title'] = "Photos";
        
        $data['list'] = $this->Post->get_all();
        
        foreach ($data['list'] as $a):
        $id = $a['ID'];
        endforeach;
        
        $data['tag'] = $this->Post->get_tags($id);
        
        $this->load->library('pagination');
        
        $config['base_url'] = site_url() . '/welcome/all';
        $config['total_rows'] = 2;
        $config['per_page'] = 1;
        
        $this->pagination->initialize($config);
        echo $this->pagination->create_links();
        
        $this->load->view('meta', $data);
        $this->load->view('header', $data);
        $this->load->view('archive', $data);
    }

}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */
#2

[eluser]Zeeshan Rasool[/eluser]
Have you pass the per page limit to each funcion?
#3

[eluser]georgerobbo[/eluser]
Do I need to? I only want to use pagination of the function all?




Theme © iAndrew 2016 - Forum software by © MyBB