【PHP】フレームワーク CakePHP 12ホール目【笑】
■ このスレッドは過去ログ倉庫に格納されています
0005nobodyさん
2011/07/01(金) 19:38:21.72ID:???- routes.php
Router::connect('/m/', array('controller' => 'home', 'action' => 'index', 'prefix' => 'mobile'));
Router::connect('/m', array('controller' => 'home', 'action' => 'index', 'prefix' => 'mobile'));
Router::connect('/m/:controller/:action/*', array('prefix' => 'mobile'));
- app_controller.php
function afterFilter() {
if (!preg_match("/^m(\/)?/", $this->params['url']['url'])) {
$this->redirect('/m/' . $this->params['url']['url']);
}
if ($this->isMobile) {
$this->output = mb_convert_kana($this->output, 'k');
$this->output = mb_convert_encoding($this->output, 'SJIS', 'UTF-8');
}
}
こんな感じで振り分けたりしてるんだけど、
function show() {
$this->set('abc', $this->Model->find('all'));
}
function mobile_show() {
$this->set('abc', $this->Model->find('all'));
}
上記のようにコントローラにPC用と携帯用で全く同じ処理なのに
別々のアクションを作らないといけない。
これはしょうがないのかな?
もっとナイスな実装方法があれば助言お願いします
■ このスレッドは過去ログ倉庫に格納されています