Kohana 3.3 を使用して、タブ付きのインターフェイスを作成し、ルート パラメーターに基づいてアクティブなタブを検出しようとしています。
次のような 2 つの URL でのテスト:mysite.com/p/mycontroll
および:mysite.com/p/Francis-Lewis/mycontroll
私のルートは次のようになります。
Route::set('profile', 'p(/<name>)(/<controller>(/<action>))', array(
'name' => '[\w\-]+',
'controller' => '[a-z]+',
'action' => '(view|edit|save|delete|create|cancel)',
))->defaults(array(
'name' => null,
'directory' => 'profile',
'controller' => 'main',
'action' => 'index',
));
ルート自体は正常に機能しており、mycontroll
コントローラーを選択しています。ここで問題が発生します。コントローラーでは、次のようになります。
$this->request->param('controller'); // returns NULL
ビューで
<?= Request::current()->param('controller') ?> // returns NULL
しばらく頭を悩ませた後、Kohana Request クラスに関数を追加して、$_params
配列を返してそこに何が入っているかを確認しました。
返されるのは次のとおりです。
name => 'Francis Lewis'
現在のコントローラーを取得する方法はありますか?