gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-10-31 23:00:26 24 4
gpt4 key购买 nike

我正在使用 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,');

最后,在我的 View 脚本中,我有以下内容:
$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" />

换句话说,元关键字没有按应有的方式连接在一起。我究竟做错了什么?

干杯,
马特

最佳答案

那是因为 append 方法没有将更多的关键字追加到已经定义的列表中。 append 方法会将下一个标签附加到已经定义的标签中。同样,如果您选择前置,这会在您在插件中定义的标签之前添加您的新标签。

我认为,最好的办法是从插件中删除关键字占位符并将默认关键字存储在配置对象中,并在添加其他关键字的同时将它们插入 View 。

关于php - Zend Framework headMeta() - 关键字不附加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1013035/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com