2011-06-23 33 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