我正在阅读有关基本占位符用法的手册,它有这个例子:
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>");
}
// ...
}
我想几乎完全做到这一点,但我想有条件地向重复div
的 s 添加更多的类值,如果可能的话,在渲染时,当所有内容都在占位符中时。我特别想做的一件事是将“first”类添加到第一个元素,将“last”类添加到最后一个元素。我假设我必须扩展Zend_View_Helper_Placeholder
类来完成这个。