ホームページには 1 つの製品のみを表示しています。ページタイトルに商品名を表示したい。これどうやってするの?
質問する
3653 次
1 に答える
8
これを行うには複数の方法があります。
モジュールのレイアウト xml ファイル (app/design/frontend/[package]/[theme]/layout/{your_file_name}.xml にあります):
<reference name="head"> <action method="setTitle"><title>Title text here</title></action> </reference>
ここでの悪い点は、「その場で」タイトルを設定できないことです。
あなたのブロックファイルで(
_prepareLayout()
メソッドは良い場所です):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');
便利なリンク - レイアウト、ブロック、テンプレート
于 2012-07-06T14:55:16.497 に答える