2013-04-03 45 views
0

Paginator正在爲第二頁的頁面加載404頁面。問題在於這個控制器中存在_remap方法。codeigniter 2分頁不適用於_remap

我的分頁程序:

$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(); 

分頁程序加載,但是從2頁加載404頁。我怎樣才能解決這個問題,而不是刪除_remap?

+0

顯示您的_remap內容。 – JoDev

+0

我添加了我的_remap。我嘗試檢查頁面是否存在我_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); 
     } 
    }