2012-09-25 5 views
0

안녕하세요. 내보기 중 하나에서 표의 페이지 매김을 사용하려고합니다. 결과를 올바르게 반환하는 문을 찾을 수 있지만 표를 정렬 할 수있는 방법이 확실하지 않습니다. 내가 찾은 정보. 여기 cakephp 페이지 매김 및 찾음

내가 페이지를 매기하려고 할 때 내가 얻을 수있는 모든 오류 여기
public function index_admin(){ 
    //displays all disputes related to account.id 
    //in a dashboard for an administrator user 

    $this->set('title_for_layout', 'Dispute'); 
    $this->set('stylesheet_used', 'homestyle'); 
    $this->set('image_used', 'eBOXLogoHome.png'); 
    $this->layout='home_layout'; 

    //gets the User.account_id 
    $id = $this->Auth->User('account_id'); 
    $conditions=array("OR"=> array(
     'Invoice.sender_id' => $id, 
     'Invoice.receiver_id' => $id)); 

    $receiver=$this->Dispute->find('all',array(
    'conditions'=>$conditions)); 

    $this->set('receiver',$receiver); 
    $this->paginate('Dispute'); 
    $this->set('id',$id); 


} 

당신은,하지 paginate를 호출하는 대신 find한다

  <tr> 
       <th><?php echo $this->Paginator->sort('id', 'Invoice ID'); ?></th> 
       <th><?php echo $this->Paginator->sort('dispute_date', 'Dispute Created'); ?></th> 
       <th><?php echo $this->Paginator->sort('status', 'Status'); ?></th> 
       <th>Actions</th> 
      </tr> 

    <?php foreach($receiver as $receivers):?> 

    <tr> 
     </tr><tr> 
     <td><?php echo $receivers['Invoice']['id'] ;?></td> 
     <td><?php echo $receivers['Dispute']['dispute_date'] ;?></td> 

    <?php 

    if($receivers['Dispute']['active']==1) 
    { 
     $status = 'Active'; 
     $bgcol = '#B9FAEA'; 
    } 
    else 
    { 
     $status = 'Resolved'; 
     $bgcol = '#FAB9B9'; 
    } 
    ?><td align='center' bgcolor='<?php echo $bgcol ?>'><?php echo $status ?></td> 
    <td><?php echo $this->Form->Html->link('View', 
           array('controller' => 'Messages','action'=>'viewMessage_admin',$receivers['Dispute']['id'])); ?> 
       <?php echo $this->Form->Html->link('Resolve', 
           array('controller' => 'Disputes','action'=>'resolve',$receivers['Dispute']['id'])); ?></td> 
    </tr> 


<?php endforeach; ?> 

답변

1

뷰에 대한 코드입니다 찾습니다 컨트롤러 이후 :

$id = $this->Auth->User('account_id'); 
$conditions=array("OR"=> array(
    'Invoice.sender_id' => $id, 
    'Invoice.receiver_id' => $id)); 

$receiver=$this->paginate('Dispute', $conditions); 
$this->set('receiver',$receiver); 
$this->set('id',$id); 
관련 문제