2014-01-20 93 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()); ?>