脚本宝典收集整理的这篇文章主要介绍了zend-framework – Zend Framework:部分和占位符之间的区别是什么,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
这是一个占位符的简单示例,听起来像你想要的. (保持数据)
<?PHP //this is placed in my layout above the htML and uses an action helPEr //so that a specific action is called,you Could also use view helpers or partials $this->layout()->nav = $this->action('render','menu',null,array('menu' => $this->mainMenuId)) ?> <div id="nav"> //Here the placeholder is called in the layout <?PHP echo $this->layout()->nav ?>&nbsp; </div>
在这种情况下,菜单ID是在bootstrap中设置的,但是这并不简单.
PRotected function _inITMenus() { $view = $this->getResource('view'); $view->mainMenuId = 4; $view->adminMenuId = 5; }
[编辑]
我认为一个更好的占位符示例可能是有序的.这个占位符是一个小的搜索表单,我在不同配置的几个控制器中的几个动作中使用.
在此配置中,此表单设置为仅搜索音乐艺术家,使用此占位符的控制器将具有setAction()的不同路径,不同的标签以及有时不同的占位符文本.我使用相同的表单来搜索音乐和视频数据库.
我总是使用相同的设置或者更喜欢这样做,然后我可以将其设置为插件.
//in the controller public function predispatch() { //add form $seArchForm = new Application_Form_Search(); $searchForm->setAction('/admin/music/update'); $searchForm->query->setAttribs(array('placeholder' => 'Search for Artist','size' => 27,)); $searchForm->search->setLabel('Find an Artist\'s work.'); $searchForm->setDecorators(array( array('ViewScript',array( 'viewScript' => '_searchForm.phtml' )) )); //assign form to placeholder $this->_helper->layout()->search = $searchForm; }
我在布局中使用占位符(也可以在任何视图脚本中使用).当占位符具有值时呈现搜索表单,而当占位符没有值时不呈现搜索表单.
//in the layout.phtml <?PHP echo $this->layout()->search ?>
并且只是为了完成,这里是表单用作viewscript装饰器的部分.
<article class="search"> <form action="<?PHP echo $this->element->getAction() ?>" method="<?PHP echo $this->element->getmethod() ?>"> <table> <tr> <th><?PHP echo $this->element->query->renderLabel() ?></th> </tr> <tr> <td><?PHP echo $this->element->query->renderViewHelper() ?></td> </tr> <tr> <td><?PHP echo $this->element->search ?></td> </tr> </table> </form> </article>
这个例子应该真正说明部分和占位符之间的区别.
以上是脚本宝典为你收集整理的zend-framework – Zend Framework:部分和占位符之间的区别是什么全部内容,希望文章能够帮你解决zend-framework – Zend Framework:部分和占位符之间的区别是什么所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。