本文介绍了html head 中的多描述元标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 Zend FW 中,当我使用 helper 在循环中添加描述元标记时:
$this->headMeta()->appendName('DESCRIPTION', $des);
我的 html 头中有多个元标记.
<meta name="DESCRIPTION" content="des1"/><meta name="DESCRIPTION" content="des2"/>我怎样才能防止它并在我的 html 头中有类似下面的内容:
<meta name="DESCRIPTION" content="des1 des2"/> 解决方案
像这样扩展你自己的头部视图助手.
$this->headDescription($stringToAttach);
并提供一种将值推送到 headMeta 的方法
$this->headDescription()->pushToHeadMeta();//像这样的内部调用$this->view->headMeta('description', $this->getConcatedDescription());
其他选项是使用占位符.
//查看index.phtml$this->placeholder('description')->追加($desc1);//在查看other.phtml$this->placeholder('description')->追加($desc2);//在布局中echo $this->headMeta('description', $this->placeholder('description'));
in Zend FW when I add description meta tag in loop using helper:
$this->headMeta()->appendName('DESCRIPTION', $des);
i got multi meta tags in my html head.
<meta name="DESCRIPTION" content="des1" />
<meta name="DESCRIPTION" content="des2" />
how can i prevent it and have something like below in my html head:
<meta name="DESCRIPTION" content="des1 des2" />
解决方案
Extend you own head view helper callable like this.
$this->headDescription($stringToAttach);
and offer a method to push the values to headMeta
$this->headDescription()->pushToHeadMeta();
// internal call like this
$this->view->headMeta('description', $this->getConcatedDescription());
Other option is to use placeholders.
//in view index.phtml
$this->placeholder('description')
->append($desc1);
//in view other.phtml
$this->placeholder('description')
->append($desc2);
// in layout
echo $this->headMeta('description', $this->placeholder('description'));
这篇关于html head 中的多描述元标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!