Extending Zend View Helper Placeholder
- by Sonny
I was reading the manual about basic placeholder usage, and it has this example:
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>");
}
// ...
}
I want to acommplish almost exactly that, but I'd like to conditionally add more class values to the repeating divs, at time of rendering if possible, when all the content is in the placeholder. One thing I specifically want to do is add the class of "first" to the first element and "last" to the last element. I assume that I'll have to extend the Zend_View_Helper_Placeholder class to accomplish this.