我在Zend应用程序中使用HTML5
文档类型。如果我使用XHTML1_RDFA
作为我的doctype,headMeta
视图助手允许我使用appendProperty()
函数。我知道元属性在HTML5中无效,但我还是想这么做。如何覆盖行为,以便添加这些元标记?
我在上面找到了这些相关的帖子,但他们没有回答这个具体的问题:
发布于 2013-04-12 14:37:19
我扩展了HeadMeta视图助手以允许它们。它也在http://validator.w3.org/上进行验证。
class My_View_Helper_HeadMeta extends Zend_View_Helper_HeadMeta
{
/**
* Determine if item is valid
*
* @param mixed $item
* @return boolean
*/
protected function _isValid($item)
{
if ((!$item instanceof stdClass)
|| !isset($item->type)
|| !isset($item->modifiers))
{
return false;
}
if (!isset($item->content)
&& (! $this->view->doctype()->isHtml5()
|| (! $this->view->doctype()->isHtml5() && $item->type !== 'charset'))) {
return false;
}
// <meta property= ... /> is only supported with doctype RDFa
if (!$this->view->doctype()->isRdfa()
&& !$this->view->doctype()->isHtml5()
&& $item->type === 'property') {
return false;
}
return true;
}
}
https://stackoverflow.com/questions/14586564
复制相似问题