Welcome Guest, Not a member yet? Register   Sign In
pagination beginner question
#1

[eluser]cehennem[/eluser]
Hi. I am trying to make a simple pagination test. Here is my default controller

Code:
<?
class main_page extends Controller {

    function main_page() {
        parent::Controller();
        $this->load->model('kitap_db');
        $this->load->library('pagination');
    }
    
    function index() {
        $kactane    = 3; // records per page
        $page        = $this->uri->segment(2); // page number
        if (empty($page)) $page = 0;
        
        $this->db->limit($kactane, $page);
        $sonuc = $this->db->get('kitaplar');
        
        if ($sonuc->num_rows() > 0) {
            foreach ($sonuc->result() as $birsonuc) {
                $veri['kitaplar'][] = $birsonuc;
            }
        }
        
        $config['uri_segment'] = 2;
        $config['num_links'] = 5;
        $config['per_page'] = $kactane;
        $config['base_url'] = 'http://localhost/test/page';
        $config['total_rows'] = $this->db->count_all_results('kitaplar');
        $this->pagination->initialize($config);
        $veri['sayfalar'] = $this->pagination->create_links();
        
        
        $this->load->view('anasayfa', $veri);
    }


}

And routes

Code:
$route['page/(:num)'] = "main_page/index/page/$1";

index.php is located under /test/

Now everything works ok on all pages page/1 page/2 etc. But when I go http://localhost/test/page/ (no page specified) I get 404 Not Found. I think here 'page' becomes a function name which does not exists. I want 1st page to be shown if no page specified like ..com/test/page/

I've tried to route it but couldn't success.

Thanks guys.


Messages In This Thread
pagination beginner question - by El Forum - 11-20-2010, 03:53 PM
pagination beginner question - by El Forum - 11-20-2010, 04:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB