Magento 布局 module_default

发布于 2024-09-28 09:53:48 字数 300 浏览 1 评论 0原文

我创建了一个具有多个不同控制器的模块,因此具有不同的页面。

我想在我自己的每个页面上都有一个默认的侧边栏,但不在网站的其余部分上。

当我使用 时,它显然会在整个网站中传播。

当我尝试 时什么也没有发生。

因此,我不得不为模块的每个单独页面复制并粘贴整个布局。

magento布局中有没有办法只指定一次,属于模块的每个页面共享一些xml?

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 be shared by each page that belongs to a module?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

累赘 2024-10-05 09:53:48

当然,这绝对是可能的。当您使用 loadLayout 加载布局时,该函数有隐式参数,即使它通常被称为无参数。 loadLayout 函数实际上将采用一个或多个字符串来默认加载布局。这意味着您可以执行以下操作:

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

为该句柄定义布局,如下所示:

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

希望有帮助!

谢谢,

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

泪是无色的血 2024-10-05 09:53:48

对于与其中一个页面相关的每个布局部分,添加更新参考。

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

customer.xml 中的客户帐户页面也使用同样的内容。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文