2011-06-23 36 views
0

使用Zend_Layout的我beginner.I在Zend的layout.phtml以下的div結構我如何自舉

<div id='outer'>//start outer 
<div id='header'>//start header......</div>// end header 
<div id='content'>//start content......</div>// end content 
<div id='footer'>//start footer......</div>// end footer 
</div>// end outer 

在這裏我要的頁面類似header.phtml的頭部分和footer.phtml分離爲頁腳部分。我怎樣才能在bootsrap文件中使用Zend_Layout來上述結構

回答

1

此行添加到您的引導文件:

Zend_Layout::startMvc(array('layoutPath' => 'PATH TO YOUR LAYOUT DIRECTORY')); 

編輯:

分離頁眉和頁腳在不同的文件中使用此代碼:

<div id='outer'>//start outer 
    <?php echo $this->render('header.phtml'); ?> 
    <?php echo $this->render('content.phtml'); ?> 
    <?php echo $this->render('footer.phtml'); ?> 
</div>// end outer 
+0

我在哪裏添加上面的代碼在引導文件?我們在_initViewHelper()中添加了那個嗎?如果是的話,我的layout.phtml路徑是「應用程序/佈局/腳本」我需要在PATH到你的佈局目錄給路徑嗎? – mymotherland

+0

將其添加到runApp()方法。按照我在回覆中提到的方式指定佈局路徑。 –

+0

我現在得到了這個觀點,我使用了「zf enable layout」,它在application.ini中添加「resources.layout.layoutPath = APPLICATION_PATH」/ layouts/scripts /「,所以我不想再指出關於佈局路徑的bootsrap文件。 ..right? – mymotherland

1

如果我明白你想填補這些DIV與他們各自所包含的內容不同文件。你可以做到這一點考慮是這樣的:

<div id='outer'> 
    <div id='header'><?= $this->render('header.phtml'); ?></div> 
    <div id='content'><?= $this->render('content.phtml'); ?></div> 
    <div id='footer'><?= $this->render('footer.phtml'); ?></div> 
</div> 

在這裏,您可以管理header.phtmlcontent.phtmlfooter.phtml分開。

+0

我現在正在使用這種方式,但爲什麼我們需要在引導文件中使用Zend_Layout :: startMvc – mymotherland

+0

@Dinesh:對於此解決方案,您無需在引導程序中執行任何操作,但請確保您的文件路徑應該沒問題,謝謝。 – NAVEED

+0

好的,謝謝。 – mymotherland