[英]Setting the page title, meta description and keywords from the Block / phtml template in magento widget
[英]Magento - Set Category meta title, keywords and description
我的網站上有一個鞋子類別。 我在目錄/類別下為該類別提供的元標題、描述和關鍵字沒有反映。 這不是特定於某個類別,我只是以鞋子為例。
我不想在布局文件上使用 settitle、setkeyword、setdescription 來設置上述內容。 為什么默認的 magento 功能不起作用。
如果您能指出應用默認值的區域,將會有很大幫助。
對於默認 magento 主題中的類別布局,設置元標記的區域為:
//file: app/code/core/Mage/Catalog/Block/Category/view.php
//class: Mage_Catalog_Block_Category_View
//function: protected function _prepareLayout()
//...
$category = $this->getCurrentCategory();
if ($title = $category->getMetaTitle()) {
$headBlock->setTitle($title);
}
if ($description = $category->getMetaDescription()) {
$headBlock->setDescription($description);
}
if ($keywords = $category->getMetaKeywords()) {
$headBlock->setKeywords($keywords);
}
//...
所以我認為要問自己的問題是為什么$category->getMetaTitle()
錯誤的,或者在布局后期覆蓋$category->getMetaTitle()
或者我的主題是否重寫了函數Mage_Catalog_Block_Category_View::_prepareLayout()
.
您可能希望在所有 .xml 文件中搜索如下代碼:
<reference name="head">
<action method="setTitle" translate="title" module="catalog"><title>Site Map</title></action>
</reference>
因為任何模塊都可以使用 XML 更改元標記。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.