Magento - 使用 local.xml 重新排列欢迎消息、搜索框和目录导航

发布于 2024-11-01 23:17:40 字数 1316 浏览 0 评论 0原文

我正在尝试实现一种布局,其中默认欢迎消息位于搜索框的顶部,后面是目录导航,类似于他们的 这里

我希望通过 local.xml 文件来做到这一点。到目前为止,我有这个:

<?xml version="1.0" ?> 
<layout>
  <default> 

    <!-- add the local stylesheet -->
    <reference name="head">
      <action method="addCss"><stylesheet>css/local.css</stylesheet></action>
    </reference>

    <reference name="header">
      <action method="unsetChild"><alias>topSearch</alias></action>
      <action method="insert"><blockName>top.search</blockName><sublingName>catalog.topnav</sublingName><after>1</after></action>
    </reference>   

  </default>  
</layout>

我能够取消设置搜索框,但无法将其插入到目录导航之前 - 什么也没有发生。我也尝试过以这种方式插入

    <reference name="top.nav">
      <action method="insert"><blockName>top.search</blockName><sublingName>catalog.topnav</sublingName><after>1</after></action>
    </reference>

,但仍然不起作用。我在这里可能做错了什么?

我在这里真的很困惑,这种方法可以吗?我检查了 header.phtml,发现我只需切换默认欢迎消息和搜索框的行,我就完成了!但我想这意味着我必须复印一份 header.phtml 到我自己的主题。这是更好的方法吗?

谢谢!

i'm trying to achieve a layout wherein the default welcome message sits on top of the search box followed by the catalog nav similar to what they have here.

i was hoping to do this through the local.xml file. so far i have this:

<?xml version="1.0" ?> 
<layout>
  <default> 

    <!-- add the local stylesheet -->
    <reference name="head">
      <action method="addCss"><stylesheet>css/local.css</stylesheet></action>
    </reference>

    <reference name="header">
      <action method="unsetChild"><alias>topSearch</alias></action>
      <action method="insert"><blockName>top.search</blockName><sublingName>catalog.topnav</sublingName><after>1</after></action>
    </reference>   

  </default>  
</layout>

i was able to unset the searchbox but i couldn't make it insert before the catalog nav - nothing happens. i also tried inserting it this way

    <reference name="top.nav">
      <action method="insert"><blockName>top.search</blockName><sublingName>catalog.topnav</sublingName><after>1</after></action>
    </reference>

but it still doesn't work. what could i be doing wrong here?

i'm getting really confused here, is this kind of approach okay to do? i checked the header.phtml and saw that i only have to switch the lines for the default welcome message and searchbox and i'm done! but i guess this would mean that i would have to make a copy
of the header.phtml to my own theme. would this be a better approach?

thanks!

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

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

发布评论

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

评论(1

一影成城 2024-11-08 23:17:40

为您自己的主题复制 header.phtml。正如您所看到的,它控​​制输出的顺序,并且没有任何魔法可以使其改变 - 除了用 javascript 破解它,但这更糟糕......

为每个主题拥有不同文件夹的目的是允许这种排序覆盖所以利用它来发挥你的优势。

Make a copy of header.phtml for your own theme. As you've seen it controls the order of output and there is no magic that can make it change otherwise - except for hacking it with javascript but that's worse...

The purpose of having different folders for each theme is to allow exactly this sort of override so use it to your advantage.

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