Router::connect
CakePHP 1.3.6
お題:UsersController::mobile_hoge()を呼び出す以下のurlを出力してみる
/m/139c765e92697cb6b5cb096066d462d5/hoge?foo=bar
routes.php
<?php Router::connect('/m/:var/hoge/', array('controller' => 'users', 'action' => 'hoge', 'prefix' => 'mobile', 'mobile' => true), array('var' => '[a-zA-Z0-9]{32}') );
view
<?php // link echo $this->Html->link( 'hoge', array('controller' => null, 'action' => 'mobile_hoge', 'mobile' => true, 'var' => session_id(), '?' => 'foo=bar') ); // form echo $this->Form->create( null, array( 'url' => array( 'controller' => false, 'action' => 'mobile_hoge', 'mobile' => true, 'var' => session_id(), '?' => 'foo=bar' ), 'encoding' => null, // accept-charsetを入れない 'id' => false // idは使用しない )); echo $this->Form->end('done.');