2013-04-03 4 views
0

Paginator загружает 404 страницу для страниц со второго. Проблема Gues заключается в методе _remap, существующем в этом контроллере.codeigniter 2 pagination не работает с _remap

Мой Paginator:

$this->config->load('pagination', TRUE); 
    $config = array_merge($this->config->item('pagination'), Array(
     'base_url' => site_url() . "/welcome", 
     'total_rows' => count($commentsOfInterview), 
     'per_page' => 2, 
     'uri_segment' => 2, 
    )); 
    $this->pagination->initialize($config); 

    $page = ($this->uri->segment(1)) ? $this->uri->segment(1) : 1; 
    $commentsList['comments'] = $this->em->getRepository('Entities\Comment')->findPageOfActive($page, $config["per_page"], 'DESC', $lastInterviewId); 
    $commentsList['links'] = $this->pagination->create_links(); 

Paginator загружается, но для страниц из 2 загружает страницу 404. Как я могу решить эту проблему, не удаляя _remap?

+0

Показать ваш _remap-контент. – JoDev

+0

Я добавил свой _remap. Я пытаюсь проверить, существует ли страница i _remap, потому что когда я использую _remap, CI перестает проверять ее самостоятельно –

+0

Я хотел бы добавить еще один, если на мой _remap, который будет проверять, является ли сегмент (2) числовым, и передает обратно управление в метод, но так, что будет загружена вторая страница paginator. Как это реализовать? –

ответ

0
public function _remap($method) { 
     if(method_exists($this, $method)){ 
      if($this->em->getRepository('Entities\User')->getUserId() === null && $this->em->getRepository('Entities\User')->getUserRole() !== 'VISITOR'){ 
       $this->em->getRepository('Entities\User')->setUserRole('VISITOR'); 
       $options=array(
        'client_id' => 'interview', 
        'client_secret' => 'interview', 

       ); 
       $params=array(
        'scope'=>'email', 
        'cur_uri' => 'http://192.168.0.129/index.php/' . $this->uri->uri_string(), 
        'redirect_uri' => 'http://192.168.0.129/index.php/UserController/authorise/muloqot', //?connect=muloqot', 

       ); 
       $client = new Oauth2_MuloqotClientAPI($options); 
       $client->isAuthorized($params); 
      } 
/*   else if($this->em->getRepository('Entities\User')->getUserRole() === 'VISITOR'){ 
       $this->em->getRepository('Entities\User')->deleteSessionData(); 
      }*/ 
      if ($this->uri->segment(3)) { 
       return $this->$method($this->uri->segment(3)); 
      } else return $this->$method(); 
     } else { 
      $error404 = site_url($this->router->routes['404_override']); 
      redirect($error404); 
     } 
    } 
Смежные вопросы