在magento的主页上设置自定义页面标题

在magento的主页上设置自定义页面标题,magento,Magento,我只在主页上显示一个产品。我想在页面标题中显示产品名称。我如何才能做到这一点?您有多种方法可以做到这一点: 在模块的布局xml文件中(位于app/design/frontend/[package]/[theme]/layout/{your_file_name}.xml): <reference name="head"> <action method="setTitle"><title>Title text here</title></

我只在主页上显示一个产品。我想在页面标题中显示产品名称。我如何才能做到这一点?

您有多种方法可以做到这一点:

  • 在模块的布局xml文件中(位于app/design/frontend/[package]/[theme]/layout/{your_file_name}.xml):

    <reference name="head">
        <action method="setTitle"><title>Title text here</title></action>
    </reference>
    
    public function _prepareLayout() 
    {
        $headBlock = $this->getLayout()->getBlock('head');
        $headBlock->setTitle('Title text here');
        return parent::_prepareLayout();
    }
    
    Mage::app()->getLayout()->getBlock('head')->setTitle('Title text here');
    
  • 其他任何地方:

    <reference name="head">
        <action method="setTitle"><title>Title text here</title></action>
    </reference>
    
    public function _prepareLayout() 
    {
        $headBlock = $this->getLayout()->getBlock('head');
        $headBlock->setTitle('Title text here');
        return parent::_prepareLayout();
    }
    
    Mage::app()->getLayout()->getBlock('head')->setTitle('Title text here');
    
  • 有用的链接-