更改 Magento 中所有模块页面的设计

发布于 2024-09-19 05:01:44 字数 363 浏览 3 评论 0原文

我正在 Magento 中创建一个自定义模块,一切进展顺利...除了我想更改模块中所有页面使用的基本布局模板。我做了一些谷歌搜索但收效甚微。有人有答案吗?我想做一些类似的事情:

...
<optionbox>
  <reference name="root">
    <action method="setTemplate"><template>page/empty.phtml</template></action>
  </reference>
</optionbox>

正如你可能猜到的,这是一个灯箱......我猜我是一个贪吃惩罚的人:)

I'm doing a custom module in Magento and everything is going swimmingly... except I want to change the base layout template that all pages in the module use. I've done some googling with little success. Anyone have any answers? I want to do something along the lines of:

...
<optionbox>
  <reference name="root">
    <action method="setTemplate"><template>page/empty.phtml</template></action>
  </reference>
</optionbox>

As you may guess, it's a lightbox... I'm a glutton for punishment I guess :)

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

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

发布评论

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

评论(3

养猫人 2024-09-26 05:01:44

我注意到您的布局更新的根为 ,理论上应该涵盖该模块下的所有控制器和操作。但是,我只见过使用 完成此操作,其中 index 来自模块中的 IndexController 。因此,也许可以尝试将其替换为您的控制器名称:

<layout>
 ...
 <optionbox_index>
   <reference name="root">
     <action method="setTemplate"><template>page/empty.phtml</template></action>
   </reference>
 </optionbox_index>

另外,您应该尝试 Alan Storm 的 LayoutViewer 模块< /a>,使用说明此处。这可能会帮助您调试它。

干杯,
京东

I notice that you've got the root of your layout update as <optionbox> which in theory should cover all controllers and actions under that module. However, I've only ever seen this done with <optionbox_index> where index is from IndexController in your module. So perhaps try this replaced with your controller name:

<layout>
 ...
 <optionbox_index>
   <reference name="root">
     <action method="setTemplate"><template>page/empty.phtml</template></action>
   </reference>
 </optionbox_index>

Also, you should try Alan Storm's LayoutViewer module, instructions on it's use here. That might help you debug it.

Cheers,
JD

旧时模样 2024-09-26 05:01:44

在我的模块中,我在控制器操作中执行此操作,如下所示:

public function listAction() {
  $this->loadLayout();
  $this->getLayout()->getBlock('root')->setTemplate('page/2columns-right.phtml');
  $this->renderLayout();
}

In my modules I do it within the controller action like so:

public function listAction() {
  $this->loadLayout();
  $this->getLayout()->getBlock('root')->setTemplate('page/2columns-right.phtml');
  $this->renderLayout();
}
彼岸花似海 2024-09-26 05:01:44

您是否尝试过将该片段插入到您的 optionbox.xml 布局文件中?看起来它应该像你拥有的那样工作?

have you tried inserting that snippet into your optionbox.xml layout file? It looks like it should work as you have it?

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