CakePHP:从视图中添加元nofollow标签到布局

JD *_*cks 4 cakephp cakephp-1.3

我希望能够在CakePHP中从视图(或控制器,如果可能)添加元标记

我有一个类似的页面,/mycontroller/myview但是当使用以下过滤器访问它时:

/mycontroller/myview/page:2/max_price:500

然后我想添加meta no follow标签.

HtmlHelper类有一个meta方法.

当我这样称呼时:

$this->Html->meta('keywords', 'test test test', array('inline'=>false));
Run Code Online (Sandbox Code Playgroud)

它会创建一个这样的元标记:

<meta name="keywords" content="test test test" />
Run Code Online (Sandbox Code Playgroud)

但是,当我这样称呼时:

$this->Html->meta('robots', 'noindex, nofollow', array('inline'=>false));
Run Code Online (Sandbox Code Playgroud)

我自然会期望并希望它创造这个:

<meta name="robots" content="noindex, nofollow" />
Run Code Online (Sandbox Code Playgroud)

相反,我得到了这个:

<link href="http://www.example.com/mycontroller/noindex, nofollow" type="application/rss+xml" rel="alternate" title="robots" />
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

ple*_*ong 8

文档页面(最后一行)

如果要添加自定义元标记,则应将第一个参数设置为数组.要输出机器人noindex标记,请使用以下代码:

echo $this->Html->meta(array('name' => 'robots', 'content' => 'noindex'));
Run Code Online (Sandbox Code Playgroud)

在你的情况下:

echo $this->Html->meta(array('name' => 'robots', 'content' => 'noindex, nofollow'),null,array('inline'=>false));
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助