Magento-在所有页面中创建一个固定的块 [英] Magento - create a fixed block in all pages

查看:63
本文介绍了Magento-在所有页面中创建一个固定的块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不包括模块名称的情况下在所有页面(包括主页)的右栏中创建一个块?

how can I create a block in the right column visible in all pages including the homepage without taping the module name?

谢谢.

推荐答案

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

Hoping to have understood well your question...

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

1) Create a module (for example Mynamespace/Mymodule)

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

2) Create a block in your module (for example Mynamespace/Mymodule/Block/Myblock)

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

3) Create a phtml file for that block (YOURTHEMEDIR/template/mymodule/myblock.phtml)

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

4) Edit config.xml of the module "Mymodule" so that it will load a layout update file (YOURTHEMEDIR/layout/mymodule.xml):

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

5)在mymodule.xml内放入如下内容:

5) Inside your mymodule.xml put something like this:

<?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>

这篇关于Magento-在所有页面中创建一个固定的块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆