無理やりですが。
対象のテーブルはServersとします。
[cakeのインストール先]/app/views/smarty.phpの69行目あたりにtemplate_dirの定義を追加。
$this->smarty->cache_dir = TMP.'smarty'.DS.'cache'.DS; $this->smarty->template_dir = dirname(__FILE__); # これを追加 $this->smarty->error_reporting = 'E_ALL & ~E_NOTICE';
[cakeのインストール先]/app/views/layouts/smarty/default.tplを修正。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
{$html->charset()}
<title>{$title_for_layout}</title>
{$html->meta('icon')}
{$html->css('cake.generic')}
{$scripts_for_layout}
</head>
<body>
{$content_for_layout}
</body>
</html>
[cakeのインストール先]/app/views/elements/にpaging.tplを作成。
{assign_assoc var='CounterArray' value='format=>全%pages%ページ中の%page%ページ目を表示中 全%count%件中の%start%件目から%end%件目の%current%件を表示中'}
{$paginator->counter($CounterArray)}
</p>
<table cellpadding="0" cellspacing="0" border="1">
<tr>
{foreach from=$paging_data.0.$model key=key item=head}
<th>{$paginator->sort($translate.$key,$key)}</th>
{/foreach}
<th>Actions</th>
</tr>
{foreach from=$paging_data item=data}
<traltrow,altrow2"}">
{foreach from=$data.$model key=key item=item}
<td>
{$item}<br>
</td>
{/foreach}
{assign var='id' value=$data.$model.id}
{assign_assoc var='view_link' value='action=>view,$id'}
<td>
{$view_link}
{$html->link('View', "view/$id")}
{$html->link('Edit', "edit/$id")}
{$html->link('Delete', "delete/$id")}
</td>
</tr>
{/foreach}
</table>
</div>
<div>
{$paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'))}
| {$paginator->numbers()}
{$paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'))}
</div>
例えば
create table translates (
id serial NOT NULL,
word text,
translate text,
created timestamp(0) default NULL,
modified timestamp(0) default NULL
);
こんな感じで。対象のテーブルの各項目をwordに、その訳をtranslateに格納しておきます。
translatesテーブルを使う。
var $uses = array('Servers','Translates')
index functionの中を修正。
function index() {
$this->Server->recursive = 0;
//$this->set('servers', $this->paginate());
$this->set(
'translate',$this->Translate->find(
'list',
array('fields'=>
array('Translate.word','Translate.translate')
)
)
);
$this->set('model','Server');
$this->set('paging_data', $this->paginate());
}
index.ctpの代わりにindex.tplを作成。
<div>
<h2>{$model}</h2>
<p>
{include file="elements/paging.tpl"}
Related posts: