2014-10-24 3 views
1

의견이있는 뉴스가 있습니다. 나는 의견 페이지를 매기는하고 싶지만이 같은 오류가 있습니다요소를 사용하는 동안 페이지 매김기 오류가 발생했습니다.

Notice (8): Undefined index: count [CORE\Cake\View\Helper\PaginatorHelper.php, line 646] 

을 물론 나는 번호가 표시되지 않는 등의 링크

어떻게이 문제를 해결하기 위해 어떤 생각을 가지고 있습니까? 감사합니다.

구성 요소 :

public function viewFromNewsId($news_id = null) { 
$this->NewsComment->recursive = 0; 
$this->Paginator->settings = array('conditions' => array('NewsComment.news_id' => $news_id, 'NewsComment.is_active' => '1'), 'limit' => 5, 'order' => array('NewsComment.id' => 'desc')); 
$newsComments = $this->Paginator->paginate('NewsComment'); 
if (isset($this->params['requested'])){ 
return $newsComments; 
} 
} 

요소 :

$newsIdFromUrl = $this->params['pass'][0]; 
$newsComments = $this->requestAction("newsComments/viewFromNewsId/$newsIdFromUrl"); 
foreach($newsComments as $newsComment): 
$this->App->showNewsComment($newsComment); 
endforeach; 
echo $this->Paginator->counter('Liczba newsów: {:count} | '); 
echo $this->Paginator->prev('<< wstecz', null, null, array('class' => 'disabledText')); 
echo $this->Paginator->numbers(array('separator' => ' ', 'before' => ' | ', 'after' => ' | ', 'modulus' => '10')); 
echo $this->Paginator->next('dalej >>', null, null, array('class' => 'disabledText')); 
echo "<br />"; 

보기 : echo $this->element('newsViewComments');

답변

0

나 자신에 의해 답을 발견;)

에 체크 아웃 - 어쩌면 당신의 사람 것 이것을 사용하십시오. 나는 같은 문제를 가진 많은 사람들이 있다는 것을 압니다.

답변 : 그냥 같이 컨트롤러의 요소, 편집보기 기능을 사용하지 않는 :

public function view($id = null) { 
$this->Paginator->settings = array('conditions' => array('NewsComment.news_id' => $id), 'limit' => 5, 'order' => array('NewsComment.id' => 'desc')); 
$newsComments = $this->Paginator->paginate('NewsComment'); 


$options = array('conditions' => array('News.' . $this->News->primaryKey => $id)); 
$news = $this->News->find('first', $options); 
$this->set(compact('news', 'newsComments')); 
} 

어떻게 당신이 당신의 view.ctp에서 두 변수가 있습니다 첫 번째 $news - 뉴스 데이터를 두 번째 것. $newsComments foreach 및 페이지 매김과 함께 사용하십시오.

그러나 모델에서 올바른 연관성을 기억하십시오.