如何更改Magento指定页面的标题(title)?

2,480 人次阅读
没有评论

共计 1104 个字符,预计需要花费 3 分钟才能阅读完成。

1.首先你必须找到模版包下的head.phtml,路径如app/design/frontend/your_package/your_theme/template/page/html/head.phtml

2.查找一下行:

[php] view plaincopy

<title><?php echo $this->getTitle() ?></title>

[/php]

3.替换为如下的代码:

[php] view plaincopy

<title><?php echo ($this->getMyTitle()) ?
Mage::getStoreConfig(‘design/head/title_prefix’).’ ‘.$this-
>getMyTitle().’ ‘.Mage::getStoreConfig(‘design/head/title_suffix’)
: $this->getTitle(); ?></title>

[php]<!–more–>

4.查找比如customer.xml的layout文件,这里我们改登录页的title

[php] view plaincopy

<customer_account_login translate="label">
<label>Customer Account Login Form</label>
<!– Mage_Customer –>
<remove name="right"/>
<remove name="left"/>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"/>
</reference>
<!– New reference for page title starts –>
<reference name="head">
<action method="setMyTitle" translate="title"><title>Buyer
Login</title></action>
</reference>
<!– // New reference for page title ends –>
</customer_account_login>

[/php]

5.刷新下,注意缓存问题,应该能看到title变了,其他的类推!

正文完
 0