0

ホームページには 1 つの製品のみを表示しています。ページタイトルに商品名を表示したい。これどうやってするの?

4

1 に答える 1

8

これを行うには複数の方法があります。

  1. モジュールのレイアウト xml ファイル (app/design/frontend/[package]/[theme]/layout/{your_file_name}.xml にあります):

    <reference name="head">
        <action method="setTitle"><title>Title text here</title></action>
    </reference>
    

    ここでの悪い点は、「その場で」タイトルを設定できないことです。

  2. あなたのブロックファイルで(_prepareLayout()メソッドは良い場所です)

    public function _prepareLayout() 
    {
        $headBlock = $this->getLayout()->getBlock('head');
        $headBlock->setTitle('Title text here');
        return parent::_prepareLayout();
    }
    
  3. どこか他の:

    Mage::app()->getLayout()->getBlock('head')->setTitle('Title text here');
    

便利なリンク - レイアウト、ブロック、テンプレート

于 2012-07-06T14:55:16.497 に答える