2010-07-07 7 views
0

cakephp 1.26을 사용하고 페이지 매김을하고 있습니다. 다음 코드를 알려주십시오. 코드에서 무엇이 잘못되었는지 알 수 없습니다.내 코드의 도움이 필요합니다

<table> 
<tr><td> 
     <?php echo $paginator->numbers(); ?> 
<?php 
    echo $paginator->prev('Previous', null, null); 
    echo $paginator->next(' Next', null, null); 
?> 

</td></tr> 
</table> 

답변

2

코드가 잘못되었습니다. 함수 호출 내에서 할당을 할 수 없습니다. 하나는 수행

$this->set('posts', $this->paginate('Post',array(
        'order' => array('Post.created' => 'DESC'), 
        'conditions' => array('Post.zero' => '0'), 
        'limit' => '6' 
       ))); 

나 : 함수 호출 내에서

$this->paginate = array(
    'order' => array('Post.created' => 'DESC'), 
    'conditions' => array('Post.zero' => '0'), 
    'limit' => '6'); 

$this->set('posts', $this->paginate('Post')); 
); 
0

이 코드가 있어야하지 :

$this->set('posts', $this->paginate = array(
    'order' => array('Post.created' => 'DESC'), 
    'conditions' => array('Post.zero' => '0'), 
    'limit' => '6') 
); 

.ctp 파일에서

$this->set('posts', $this->paginate = array('order'=>array('Post.created'=> 'DESC'), 'conditions'=>array('Post.zero'=>'0'), 'limit'='6' 
)           
        ); 

나는이 있나요?

+0

지정이 불필요하고 잘못된입니다. 두 번째 매개 변수에 배열을 전달하거나 두 번째 매개 변수를 사용하지 않을 때 호출하기 전에 클래스 변수를 할당하면됩니다. – Leo

+0

당신 말이 맞습니다,하지만 저는 곽와이의 코드가 정확하지 않다는 사실에 집중했습니다. – Anax

0

프로세스를보다 명확하게 만들 수 있습니다.

$this->paginate['Post'] = array('order'=>array('Post.created'=> 'DESC'), 'conditions'=>array('Post.zero'=>'0'), 'limit'='6')); 
$posts = $this->paginate('Post'); 
$this->set(compact('posts')); 
+0

그리고 더 짧다 -'$ this-> set ('posts', $ this-> paginate ('Post'));' – bancer

관련 문제