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

    技术2022-05-20  41

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

     

    2.查找一下行:

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

     

    3.替换为如下的代码:

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

     

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

     

    <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>

     

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

     


    最新回复(0)