2
我閱讀手冊約basic placeholder usage,它有這個例子:擴展的Zend視圖助手佔位
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
課程來完成此任務。
其實我是想在渲染如果可能的話,當所有的內容的時候設置班在佔位符中。我特別想做的一件事是將「first」類添加到第一個元素,將「last」添加到最後一個元素。 (根據這些要求更新問題) – Sonny 2010-04-05 15:29:57
我最終使用了您的解決方案,因此我將其作爲答案授予它。謝謝戈登! – Sonny 2010-04-06 20:59:13