2014-01-20 99 views
0

在我看来,使用此:Meta标签出现两次

<?= $this->headMeta()->appendName('keywords', 'my,keyword,etc,more'); ?> 
<?= $this->headMeta()->appendName('description', $link->getMetaDesc()); ?> 
<?= $this->headMeta()->appendName('title', $link->getMetaTitle()); ?> 

但是当我检查源代码出现两次。

回答

2

您呼应headMeta()视图助手多次...

<?php 
$this->headMeta() 
    ->appendName('keywords', 'my,keyword,etc,more') 
    ->appendName('description', $link->getMetaDesc()) 
    ->appendName('title', $link->getMetaTitle()); 

echo $this->headMeta(); 
?> 

对于澄清,您可以使用headMeta()经常如你所愿。但是,您不应该多次呼应它)

$this->headMeta()->appendName(...); 
$this->headMeta()->appendName(...); 
$this->headMeta()->appendName(...); 
$this->headMeta()->appendName(...); 
$this->headMeta()->appendName(...); 
$this->headMeta()->appendName(...); 
$this->headMeta()->appendName(...); 

echo $this->headMeta(); 

上述示例同样有效。

0

似乎我不应该使用$this->headMeta()不止一次。

这工作:

<?= $this->headMeta()->appendName('keywords', $link->getMetaKeys()) 
        ->appendName('description', $link->getMetaDesc()) 
        ->appendName('title', $link->getMetaTitle()); ?>