1
私はFuelPHPとPHP /フレームワークを一般的に使い慣れていて、すべての設定といくつかのコントローラを実行することができました。しかし、どのように変数を渡すことができないのですか?私はtemplate.phpファイルに設定しました。FuelPHP Frameworkのtemplate.phpファイルに変数を渡す
アプリ/ビュー/ template.php
問題のパート:
<body class="<?php echo $bodyClass; ?>">
アプリ/クラス/コントローラ/ dashboard.php
class Controller_Dashboard extends Controller_Template
{
/**
* The basic welcome message
*
* @access public
* @return Response
*/
public function action_index()
{
return Response::forge(View::forge('dashboard/index'));
}
/**
* The 404 action for the application.
*
* @access public
* @return Response
*/
public function action_404()
{
return Response::forge(Presenter::forge('dashboard/404'), 404);
}
}
アプリ/クラス/ビュー/ダッシュボード/ index.php
class View_Dashboard_Index extends ViewModel
{
/**
* Prepare the view data, keeping this in here helps clean up
* the controller.
*
* @return void
*/
public function view()
{
$this->template = $this->request()->param('bodyClass', '');
}
}
私はそれが間違っている、確かに私はそれが動作していないと私は得ることを確認しています:
Fuel\Core\PhpErrorException [ Notice ]:
Undefined variable: bodyClass
C:/Websites/Annilla/Clients/Four04 Packaging/DEV/NEW/BUILD/backend/app/views/template.php @ line 24
すべてのアイデア?
また、別のこととして、メニュー、ヘッダー、フッターなどの読み込みのような部分的な部分を追加することは可能ですか?
これをビューまたはコントローラに追加しますか?あなたの助けてくれてありがとうbtw – James
@James私は通常、Controller_Templateから拡張されたコントローラにそれを追加します。そのため、あなたのケースでは、Controller_Dashboardの中に追加してください。 – Ghost
@Jamesはここにありますhttp://fuelphp.com/docs/general /controllers/template.html thats同じこと、クラスのプロパティでテンプレートファイルを宣言し、必要に応じて '$ this-> template-> whatever'を割り当てます – Ghost