私のアプリケーション内の特定のモジュールに対して、特定のスタイル/スクリプトリソースをロードしようとしています。ここでZend Frameworkのモジュール固有のスタイル/スクリプトのブートストラップ
は、私のアプリケーション構造です:私がいる
-application
-configs
-controllers
-forms
-layouts
-models
-modules
-admin
-configs
-controllers
-models
-views
-Bootstrap.php
-views
-Bootstrap.php
問題がある:私は/application/modules/admin/Bootstrap.php
にheadLink()
とheadScript
を通じてロードしていたスタイルとスクリプトもある私のコントローラ/アクションでロードされていますadmin
モジュールのではありません。ここに私のBootstrap.php
の
/application/Bootstrap.php
です:
protected function _initDoctype()
{
$this->_logger->info('Bootstrap ' . __METHOD__);
//init the view
$this->bootstrap('view');
$view = $this->getResource('view');
$view->doctype('XHTML1_STRICT');
//Set title and separator
$view->headTitle('Sunny Rose Photography')
->setSeparator(' | ');
//Load global stylesheets
$view->headLink()->appendStylesheet('/styles/styles_main.css')
->headlink()->appendStylesheet('/scripts/jquery-ui-1.8.17/themes/base/jquery-ui.css');
//Load Scripts
$view->headScript()->prependFile('/scripts/jquery-1.7.1/jquery-1.7.1.js')
->headScript()->appendFile('/scripts/jquery-ui-1.8.17/ui/minified/jquery-ui.min.js')
->headScript()->appendFile('/scripts/gallery.js')
->headScript()->appendFile('/scripts/scripts_main.js');
}
/application/modules/admin/Bootstrap.php
:
protected function _initDoctype()
{
$this->bootstrap('view');
$view = $this->getResource('view');
$view->headLink()->appendStylesheet('/styles/admin/styles_admin.css');
$view->headScript()->appendFile('/scripts/admin/scripts_admin.js');
}
私は、なぜそれをやっているかまたは多分見ることができます:私は、ビューを取得していますので、メインブートスラップ(?)から。私の質問は、どのようにモジュール固有のスタイルシートやスクリプトファイルをロードするのですか?
私はこの質問が重複している場合は謝罪します。私は質問のタイトルのさまざまな文言を検索しましたが、決定的なものは見つかりませんでした。
おかげで、 ケンリクエストごとに実行されているすべてのモジュールの
'headLink'などは、' view'で呼び出す必要があるので、どのように使うのですか?すなわち '$ this-> bootstrap( 'view'); $ view = $ this-> getResource( 'view'); $ view-> headLink() - > appendStylesheet( ''); $ view-> headScript() - > appendFile( ''); ' – Ken
$ this-> _ layout-> getView(); $ this - > _ layoutは親クラスから利用可能なZend_Layoutのインスタンスです –
私はそれを取得し始めていると思います - 私はちょうどZend/Layout/Controller/Plugin/Layout.phpにどのメソッドがあるかを見ることができます。ありがとうございました。 – Ken