你有多种方法可以做到这一点:
在模块的布局xml文件中(位于app/design/frontend/[package]/[theme]/layout/{your_file_name} .xml):
<reference name="head">
<action method="setTitle"><title>Title text here</title></action>
</reference>
Run Code Online (Sandbox Code Playgroud)
这里的坏处是你不能"在飞行中"设置.
在您的块文件中(_prepareLayout()方法是个好地方):
public function _prepareLayout()
{
$headBlock = $this->getLayout()->getBlock('head');
$headBlock->setTitle('Title text here');
return parent::_prepareLayout();
}
Run Code Online (Sandbox Code Playgroud)其他地方:
Mage::app()->getLayout()->getBlock('head')->setTitle('Title text here');
Run Code Online (Sandbox Code Playgroud)有用的链接 - 布局,块和模板
| 归档时间: |
|
| 查看次数: |
3111 次 |
| 最近记录: |