2012-06-13 4 views
0

현재 두 개의 다른 모델에서 페이지 매김을 설정하려고합니다. Controller 클래스에서 나는 다음과 같은 일을 해요 : 링크가cakephp 2.0 페이징 (paginator) 문제

<?php echo $this->Paginator->numbers(array('model' => 'Model1')); ?> 
    <?php echo $this->Paginator->numbers(array('model' => 'Model2')); ?> 

결과, I 페이지의 정확한 번호를 사용하여 생성 된 뷰에서

var $paginate = array(
     'Model1' => array('limit' => 10, 'recursive' => 0, 'model' => 'Model1, 'order' => array('field1' => 'ASC'), 'paramType' => 'querystring'), 
     'Model2' => array('limit' => 10, 'recursive' => 0, 'model' => 'Model2', 'order' => array('field2' => 'ASC'), 'paramType' => 'querystring') 
    ); 

    function view($id = null) { 

     // ... 

     $models1 = $this->paginate('Model1', array('Model1.model_id => $id));   
     if ($models1) { 
      $this->set('models1', $models1); 
     } 
     $models2 = $this->paginate('Model2', array('Model2.model_id => $id)); 
     if ($models2) { 
      $this->set('models2', $models2); 
     } 
    } 

하지만 링크가 있습니다 잘못된.

  1. id

    는 무시됩니다, 즉 대신 controller/action/id?page= ...의, 나는 controller/action?page= ...를 얻을.
  2. 링크의이 부분 sort=Model1.field1&direction=ASC도 작동하지 않습니다. sort=field1&direction=ASC으로 페이지를 열 수 있습니다. 그러나 첫 번째 또는 두 번째 모델을 분류하면 어떻게 구별해야합니까?

중간에 CakePHP 1.3을 사용하면이 모든 것이 잘 작동합니다.

+0

링크에'id'을 얻기 위해, 당신은'$ this-> 모델 -> ID를 가질 필요가 = $ id'를 호출하여'paginate' 함수를 호출합니다. 하지만 여전히 링크와 비슷한 문제가 있습니다 ... – nil

답변

0

당신했습니다 모두 호출에 매겨진 Model1, 확실히 두 번째는해야한다 :

$models2 = $this->paginate('Model2', ... 
+0

죄송합니다, 그것은 오타되었습니다 – nil