Sometimes you might want to render a HTML tag with a lot of dynamic attributes in a view, of you need to create an HTML Element somewhere else were it is unlikely to use HTML with inline <?php tags.
I created a view helper that just takes an array of the attributes and returns the tag. The interesting part is thing is, that this functionality is already hidden in the Zend Framework within Zend_View_Helper_HtmlElement.
<?php
class Zend_View_Helper_AnyHtmlElement extends Zend_View_Helper_HtmlElement {
public function anyHtmlElement($tag, $value = null, array $attribs = null)
{
if ($value != null) throw new Zend_Exception('not implemented yet, we can make only <XXXXXX /> tags right now.');
$xhtml = '<' . $tag . ' ';
$xhtml .= $this->_htmlAttribs($attribs);
$xhtml .= $this->getClosingBracket();
return $xhtml;
}
}
Sometimes you might want to render a HTML tag with a lot of dynamic attributes in a view, of you need to create an HTML Element somewhere else were it...