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

Biz*_*oss 1 php xml layout magento

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

谢谢.

Fab*_*ssa 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>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)