コントローラアクションとテンプレートの構成例showアクションを作成。URLは http://localhost/frontend_dev.php/goods/show になる。
アクションからテンプレートに値を渡す
アクションでテンプレートを指定する public function executeIndex()
{
$this->setTemplate('foo');
}
apps/frontend/modules/XXX/templates/fooSuccess.php が呼ばれる。 リクエストオブジェクト public function executeIndex(sfWebRequest $request)
{
$name = $request->getPamareter('name', 'default_name');
}
リダイレクト $this->redirect('/error/message');
(メソッドの)転送 $this->forward('top','index'); # topモジュールのindexメソッドへ転送
フラッシュ $this->setFlash('mesg', 'エラーが発生しました'); # あるリクエストで設定する
↓
$mesg = $this->getFlash('mesg'); # 次のリクエストで取得する
↓ # さらに次のリクエストではもう消えていて取得出来ない
テンプレートでフラッシュを参照する <?php if($sf_flash->has('mesg')): ?>
<?php $mesg = $sf_flash->get('mesg') ?>
<?php endif ?>
|
|