2012-07-30 6 views
0

Je définis les attributs de la pagination de CodeIgniter mais j'obtiens une erreur.CodeIgniter La pagination ne fonctionne pas

1 2 3 4 5 > 

Ma pagination fonctionne aux pages 2 à 5 à l'exception de la page numéro 1. Je ne réalise pas pourquoi cela se produit. Voici ma fonction de contrôleur où le nom du contrôleur est c_forum.

function show_posts_by_chapter($id_chapter=false) { 
    if($id_chapter==false) 
     show_404(); 


    $config = array(); 
    $config["base_url"] = base_url() . "index.php/c_forum/show_posts_by_chapter/" . $id_chapter.'/'; 
    $config['total_rows'] = $this->m_forum->num_rows_by_chapter($id_chapter); 

    $config['per_page'] = 2; 
    $configp['uri_segment'] = 4; 

    $choice = $config["total_rows"]/$config["per_page"]; 
    $config["num_links"] = round($choice); 
    $this->pagination->initialize($config); 
    $page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0; 

    $data['chapter_id'] = $id_chapter; 
    $data['allowed'] = $this->_get_level(); 
    $data['count_rows'] = $config['total_rows']; 


    $data['posts_all'] = $this->m_forum->get_posts_by_chapter($config['per_page'], $page, $id_chapter); 
    $data['links'] = $this->pagination->create_links(); 
    $this->load->view('forum/show_posts', $data); 
} 

View est simple:

`<?php echo $links; ?>` 

Got answe: J'utilisé $configp['uri_segment'] = 4; et il devrait être $config['uri_segment'] = 4;

+0

Qu'entendez-vous par "pas de soulignement inférieur à 1"? –

+0

je voulais télécharger une photo, alors vous pouvez l'obtenir facilement.Mais nouveau ici. Mais le thème principal est si je frappe après après 5 je reçois 2 pas 1. –

+0

C'est probablement '$ config [" num_links "]', que se passe-t-il si vous le supprimez? –

Répondre

0

configp de $ [ 'uri_segment'] = 4;
Cela doit être
$ config ['uri_segment'] = 4;

Questions connexes