Extending Zend View Helper Placeholder
Posted
by Sonny
on Stack Overflow
See other posts from Stack Overflow
or by Sonny
Published on 2010-03-25T15:25:07Z
Indexed on
2010/04/05
15:33 UTC
Read the original article
Hit count: 693
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 div
s, 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.
© Stack Overflow or respective owner