2011-10-20 12 views
1

私はzendフレームワークでテンプレートシステムを実装しようとしています。Zend_Layoutを使用して複数のレイアウトを管理しますか?

私は基本的にすべての部分ファイルとテンプレートのバリエーションを1つのファイルに入れますが、テンプレートが増えているので、これは非常に扱いにくいものです。あなたはので、私はよくパーシャルを定義し、この構造の下

/application/layout/script/template1/partial/banner.phtml 
/application/layout/script/template1/partial/footer.phtml 
/application/layout/script/template1/variation/1.phtml 
/application/layout/script/template1/variation/2.phtml 

/application/layout/script/template2/partial/banner.phtml 
/application/layout/script/template2/partial/footer.phtml 
/application/layout/script/template2/variation/1.phtml 
/application/layout/script/template2/variation/2.phtml 

それを管理する方法手に負えないこれは で、見ることができる例

/application/layout/script/template1partial-banner.phtml 
/application/layout/script/template1partial-footer.phtml 
/application/layout/script/template1variation1.phtml 
/application/layout/script/template1variation2.phtml 
/application/layout/script/template2variation1.phtml 
/application/layout/script/template2variation2.phtml 

ため

は問題ではありません、あなただけのことができます使用する$this -> render($this -> getTemplateName()."/partials/banner.phtml");

それは主な問題であるバリエーション 私はを使用しました以前はでしたが、新しいものについては使用できません。

どうすればいいですか?

答えて

2

また、layout機能で完全なパスを定義することもできます。

$this->_helper->layout->setLayout('template1/partial/banner'); 

このタスクを実行する他の方法は、あなたの現在のアクションのレイアウトを無効にし、それを任意のphtmlファイルにレンダリングすることです。例えば、現在のアクション

$this->_helper->layout->disableLayout(); 

のための最初のdisableレイアウトは、それからちょうどこの

 $this->render("complete path to your phmtl file"); 
のように任意のHTMLファイルにレンダリング
関連する問題