Magento - 在所有页面中创建固定块

时间:2010-12-15 12:25:08

标签: xml layout magento php

如何在包含主页的所有页面中显示的右栏中创建一个块,而无需录制模块名称?

谢谢。

1 个答案:

答案 0 :(得分:5)

希望能够很好地理解你的问题...

1)创建一个模块(例如Mynamespace / Mymodule)

2)在模块中创建一个块(例如Mynamespace / Mymodule / Block / Myblock)

3)为该块创建一个phtml文件(YOURTHEMEDIR / template / mymodule / myblock.phtml)

4)编辑模块“Mymodule”的config.xml,以便加载布局更新文件(YOURTHEMEDIR / layout / mymodule.xml):

<frontend>
...
<layout>
    <updates>
    <mymodule>
        <file>mymodule.xml</file>
    </mymodule>
    </updates>
</layout>
...
</frontend>

5)在你的mymodule.xml中输入如下内容:

<?xml version="1.0"?>
<frontend>
    <layout>
        <default>
            <reference name="right">  <!-- this is the name of the right column block -->
                <block type="mymodule/myblock" name="myblock" template="mymodule/myblock.phtml" /> 
            </reference>
        </default>
    </layout>
</frontend>