【发布时间】:2011-01-31 18:56:55
【问题描述】:
我正在阅读有关basic placeholder usage 的手册,其中有以下示例:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
// ...
protected function _initSidebar()
{
$this->bootstrap('View');
$view = $this->getResource('View');
$view->placeholder('sidebar')
// "prefix" -> markup to emit once before all items in collection
->setPrefix("<div class=\"sidebar\">\n <div class=\"block\">\n")
// "separator" -> markup to emit between items in a collection
->setSeparator("</div>\n <div class=\"block\">\n")
// "postfix" -> markup to emit once after all items in a collection
->setPostfix("</div>\n</div>");
}
// ...
}
我想几乎完全做到这一点,但我想有条件地向重复的divs 添加更多类值,如果可能的话,在渲染时,当所有内容都在占位符中时。我特别想做的一件事是将“first”类添加到第一个元素,将“last”类添加到最后一个元素。我假设我必须扩展 Zend_View_Helper_Placeholder 类来完成此操作。
【问题讨论】:
标签: php zend-framework placeholder zend-view