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;
}
}
Der Beitrag wurde
am Mittwoch, den 24. März 2010 um 15:49 Uhr veröffentlicht
und wurde unter Zend Framework abgelegt.
du kannst die Kommentare zu diesen Eintrag durch den RSS 2.0 Feed verfolgen.
du kannst einen Kommentar schreiben, oder einen Trackback auf deiner Seite einrichten.