2012-01-16 22 views
0

私はcontrollerのコードに以下のコードを書いています。cakephpページ番号付きのページ分割

$this->paginate['Tag'] = array(
      'fields' => array('COUNT(tag_id) AS numbers', 'tag', 'slug'), 
      'limit' => 50, 
      'order' => 'numbers desc', 
      'recursive' => 2, 
      'group' => array('tag'), 
     ); 
$tags = $this->paginate('Tag', array('not' => array('site_id' => NULL), 'tag !=' => '')); 

.ctpファイルに以下のコードを書いてください。

<div class="row section"> 
    <div class="col col_16 pagination"> 
     <h3>Tags</h3> 
     <?php 
     foreach ($tags as $key => $tag) { 
      echo '<span>' . $this->Html->link($tag['Tag']['tag'] . ' (' . $tag[0]['numbers'] . ')', '/tags/' . $tag['Tag']['slug']) . '</span>'; 
     } 
     ?> 
    </div> 
    <div class="col col_16 pagination"> 
     <?php 
     echo $this->Paginator->first('First', null, null, array('class' => 'disabled')); 
     echo $this->Paginator->prev('Previous', null, null, array('class' => 'disabled')); 
     echo $this->Paginator->numbers(array('separator' => '')); 
     echo $this->Paginator->next('Next', null, null, array('class' => 'disabled')); 
     echo $this->Paginator->last('Last', null, null, array('class' => 'disabled')); 
     ?> 
    </div> 
    <div class="col col_16 pagination"> 
     <h5 class="margin0Px"> 
      <?php 
      echo $this->Paginator->counter(array(
       'format' => __('Page %page% of %pages%, showing %current% out of %count% total, starting on %start%, ending on %end%.', true) 
      )); 
      ?> 
     </h5> 
    </div> 
</div> 

ビュー$this->Paginatorに偽の結果が表示されます。

ここで問題は何ですか?私は何も考えていない。 Plsヘルプ。

+0

.ctpを投稿すると、タグ変数の結果が投稿されることになります.CTPは実際には関係ありません。 (btw、変数を設定しましたか?$ this-> set( 'tags'、$ tags); – Dave

+0

@Daveはい、私はそれを設定しました – gautamlakum

答えて

0

コントローラでhelpers変数を定義していますか?そうでなければ、デフォルトでPaginatorヘルパーが含まれています。それはあなたがそれを自分で含めることを忘れてはならない場合。

ドキュメント:http://book.cakephp.org/1.3/en/view/1096/Using-Helpers

+0

あなたはそれをヘルパーに追加する必要はありません。 tag_id)フィールドからのAS番号と 'group' => array( 'tag')、それは正常に動作します。 – gautamlakum

関連する問題