Zend Framework headMeta() - 关键字不附加

fis*_*eny 4 php zend-framework view-helpers

我正在使用Zend Framework 1.8.我有一个问题,headMeta()复制我的元关键字.

在我的layout.phtml中,我有
<?php echo $this->headMeta(); ?>

我有一个自定义Controller_Plugin_ViewSetup(扩展Zend_Controller_Plugin_Abstract),其中包含以下代码,在dispatchLoopStartup()函数中:
$view->headMeta()->setHttpEquiv('Content-Type', 'text/html;charset=utf-8'); $view->headMeta()->setName('keywords', 'global,generic,keywords,');

最后,在我的视图脚本中,我有以下内容:
$this->headMeta()->appendName('keywords', 'view,specific,keywords');

我期待在我的HTML源代码中,我会看到:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="keywords" content="global,generic,keywords,view,specific,keywords" />

但是,我实际上看到了这个:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="keywords" content="global,generic,keywords," />
<meta name="keywords" content="view,specific,keywords" />

换句话说,元关键字并不像它们应该那样连接在一起.我究竟做错了什么?

干杯,
马特

Kie*_*all 5

这是因为append方法不会向已定义的列表添加更多关键字.append方法会将下一个标记附加到已定义的标记.同样,如果您选择prepend,则会在您在插件中定义的标签之前添加新标签.

我认为,最好的办法是从插件中删除关键字占位符,并将默认关键字存储在配置对象中,并在添加其他关键字的同时将这些关键字插入到视图中.