在Local.xml之前和之后Magento? [英] Before And After In Local.xml Magento?

查看:63
本文介绍了在Local.xml之前和之后Magento?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法理解了如何在Magento布局中的列之间移动块:通过在<reference>标记中指定"left"或"right"属性.但是,我不明白如何更改出现块的 order .我注意到<block>标记的"before"和"after"属性与之相关,但是我不确定它们是如何工作的.如果要将块从其区域的顶部移到页面的其他位置,这些属性的正确用法和语法是什么?

I've managed to get to the point where I understand how to move blocks from column to column in my Magento layouts: via specifying a "left" or "right" attribute in the <reference> tag. However, I don't understand how to change the order in which blocks appear. I've noticed that the "before" and "after" attributes of the <block> tag have something to do it with, but I'm not sure how they work. If I want to move a block from the top of its area to anywhere else in our page, what's the proper use and syntax for those attributes?

例如,我有一个类别"页面,并且其中包含以下块:

For example, I have a Category page and I have these blocks in it:

  • view.phtml
    • list.phtml
    • view.phtml
      • list.phtml
        • toolbar.phtml
          • toolbar.phtml

          ...等等.

          我想将我的块放置在这些块内的任何位置,或放在这些块的顶部,或者使所有这些块都显示在另一个块内.如何使用local.xml文件使用之前"和之后"来实现此目的?

          I want to put my block anywhere within these blocks, or at the top of these blocks, or make all of these blocks show up inside another block. How can I use "before" and "after" to achieve this using my local.xml file?

          注意:我可以通过继承它们各自的.xml文件来手动完成此操作,但这并不是解决整个问题的好方法.

          Note: I can do it manually by inheriting their respective .xml files, but that's not a good solution to the problem as a whole.

          推荐答案

          before:用于将块定位在值中指定名称的块之前.如果使用-"值,则该块位于其块嵌套级别的所有其他块之前.

          before: Used to position the block before a block with the name specified in the value. If "-" value used the block is positioned before all other blocks of its level of block nesting.

          after:用于将块定位在值中指定名称的块之后.如果使用-"值,则该块将定位在其块嵌套级别的所有其他块之后.

          after: Used to position the block after a block with the name specified in the value. If "-" value used the block is positioned after all other blocks of its level of block nesting.

          已更新:一些随机核心布局更新的示例:

          Updated: examples from some random core layout updates:

          <reference name="right">
              <block type="catalog/product_compare_sidebar" before="cart_sidebar" name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>
          </reference>
          
          <reference name="right">
              <block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
          </reference>
          

          已更新:我相信beforeafter仅在core/text_list和类似(下降)块(即仅渲染其嵌套块的块)中工作.

          Updated: I believe before and after work only in core/text_list and similar(descendant) blocks, i.e. blocks which just render blocks their nested blocks.

          这篇关于在Local.xml之前和之后Magento?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆