ベースとして、以下のサイトのサンプルを流用します。
cakephp2.6とSmartyを連携させる
サンプルから変更したコードのみを以下に示します。
Controller
CakePHP
1<?php
2App::uses('AppController', 'Controller');
3
4class AccesslogsSmartyController extends AppController {
5 public $viewClass = 'Smarty';
6 public $uses = array('Accesslog','Accesslog');
7 public $components = array('Paginator');
8
9 var $paginate = array(
10 'limit' => '5'
11 );
12
13 public function index() {
14 $userAgent = $this->request->header('User-Agent');
15 $this->Accesslog->save(['user_agent' => $userAgent]);
16 $this->Accesslog->recursive = 0;
17
18 $this->Paginator->settings = $this->paginate;
19
20 $accesslogs = $this->Paginator->paginate('Accesslog');
21 $this->set('accesslog', $accesslogs);
22
23 }
24}
View(index.tpl)
CakePHP
1<table>
2 <th>
3 id
4 </th>
5 <th>
6 user-agent
7 </th>
8 {foreach from=$accesslog item=row}
9 <tr>
10 <td>
11 {$row['Accesslog']['id']}
12 </td>
13 <td>
14 {$row['Accesslog']['user_agent']}
15 </td>
16 </tr>
17 {/foreach}
18</table>
19<div class="pagination">
20 {{$this->Paginator->prev('<i class="fa fa-chevron-left"><<</i>', ['tag'=>'', 'escape'=>false], '<a href="#"><i class="fa fa-chevron-left"></i></a>', ['tag'=>'', 'escape'=>false, 'class'=>'disabled'])}}
21 {{$this->Paginator->numbers(['separator'=>'|', 'modulus'=>5, 'tag'=>'', 'currentClass'=>'active', 'currentTag'=>'a'])}}
22 {{$this->Paginator->next('<i class="fa fa-chevron-right">>></i>', ['tag' => '', 'escape'=>false], '<a href="#"><i class="fa fa-chevron-right"></i></a>', ['tag'=>'', 'escape'=>false, 'class'=>'disabled'])}}
23</div>
表示は以下のようになります。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/01/24 02:06