开发者

Magento layout module_default

开发者 https://www.devze.com 2023-01-20 16:55 出处:网络
I have created a module with several different controllers and therefore different pages. I want to have a default sidebar on each of my own pages but not the rest of the site.

I have created a module with several different controllers and therefore different pages.

I want to have a default sidebar on each of my own pages but not the rest of the site.

when i use the <default></default> it obviously propogates throughout the entire site.

When i try <mymodule_default></mymodule_default> nothing happens.

I am therefore left with having to copy and paste my whole layout for each seperate page of my module.

Is there any way in magento layouts to specify only once, some xml that is to b开发者_C百科e shared by each page that belongs to a module?


Sure, this is definitely possible. When you load a layout using loadLayout, there are implicit arguments to the function, even though it is typically called sans arguments. The loadLayout function will actually take one or more strings for layouts to load by default. Which means that you can do this:

$this->loadLayout(array('default', 'your_layout_handle'));

Define a layout for that handle like so:

<layout>
    <your_layout_handle>
        <reference name="left">
             <block type="yourmodule/yourblock" />
        </reference>
    </your_layout_handle>
</layout>

Hope that helps!

Thanks, Joe


For each layout section that relates to one of your pages add an update reference.

<mymodule_page_index>
    <update handle="mymodule_default"/>
</mymodule_page_index>

The same thing is used for customer account pages in customer.xml.

0

精彩评论

暂无评论...
验证码 换一张
取 消