Dali
Dali

Reputation: 7882

Magento - create a fixed block in all pages

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

Thank you.

Upvotes: 2

Views: 3477

Answers (1)

Fabrizio D'Ammassa
Fabrizio D'Ammassa

Reputation: 4769

Hoping to have understood well your question...

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

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

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

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

Upvotes: 6

Related Questions