0
votes

I'm creating a pagination in CodeIgniter 2.1.3. The url of every link is missing their base_url I have created for them. For example, they show only localhost/2, or localhost/3,... on those links respectively when I hover on them.

Here is my Controller:

public function default_page() {
    $values = $this->maction->get_user_info( $_SESSION['id'] );
    if ( $values ) {
        $congif['base_url'] = base_url()."home/default_page/";
        // I aslo tried
        // $congif['base_url'] = site_url("home/default_page/");
        $config['total_rows'] = $this->maction->get_all_num_rows();
        $config['per_page'] = 10;
        $config['num_links'] = 5;
        $offset = 3;
        // I also tried
        // $offset = $this->uri->segment( 3 );
        $config['last_tag_open'] = "<div class='pagination'>";
        $config['last_tag_close'] = "</div>";
        $config['prev_link'] = "&laquo;";
        $config['next_link'] = "&raquo;";
        // $config['use_page_numbers'] = TRUE;
        $this->pagination->initialize( $config );                   
        $data['posts'] = $this->maction->get_all_posts( $config['per_page'] , $offset );
        $data['pagination'] = $this->pagination->create_links();

        $this->load->view('template/header');
        $this->load->view('default', $data);
        $this->load->view('template/footer');
    }
}

Here is my Model:

public function get_all_posts( $per_page, $offset ) {
    $sql = "SELECT * FROM user INNER JOIN content 
            ON user.user_id = content.crby ORDER BY 
            content.content_id DESC LIMIT $per_page, $offset";
    return $this->db->query( $sql );
}
2
What is the base_url and index_page set to in your config/config.php file? - Nathanael

2 Answers

1
votes

It should be $config['base_url'], not $congif

0
votes

I think it should be base_url() instead of base_url.