相关产品的放置-Magento

相关产品的放置-Magento,magento,Magento,我有一个magento安装,我需要将相关产品放置在中心柱中。这是最简单的部分。我搬家了 <block type="catalog/product_list_related" name="catalog.product.related" after="container1" template="catalog/product/list/related.phtml"/> 从右侧参照图块到中心参照图块的底部 这样我就可以把相关的产品放在中间的柱子上,但一直放在底部 我需要将相关产品放

我有一个magento安装,我需要将相关产品放置在中心柱中。这是最简单的部分。我搬家了

<block type="catalog/product_list_related" name="catalog.product.related" after="container1" template="catalog/product/list/related.phtml"/>

从右侧参照图块到中心参照图块的底部

这样我就可以把相关的产品放在中间的柱子上,但一直放在底部

我需要将相关产品放置在div中价格块的正上方(类别:product shop)

我试图在XML中使用After/before参数来定位它,但这似乎不起作用


如果我将块代码放在XML的更高位置,它根本不会显示

正确移动块非常容易(即使用最佳实践)。最佳实践包括尽可能不自定义任何核心布局文件,以及使用原始块实例而不是重新实例化它们。所有这些都可以通过使用可供最终实现者使用的自定义布局文件来实现

在自定义主题的布局文件夹(例如app/design/frontend/[package]/[theme]/layout/local.xml)中创建一个local.xml文件,并在其中添加以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <!--
        In Magento v1 a move is accomplished by unsetting in one place
        and inserting in another. This is possible using just layout xml
        when the "new" parent block is a "Mage_Core_Block_Text_List"
        instance. Otherwise a template needs editing.

        In Magento v2 there will be actual "move" functionality.
    -->
    <catalog_product_view>
        <reference name="right">
            <!-- remove the block name from a parent -->
            <action method="unsetChild">
                <block>catalog.product.related</block>
            </action>
        </reference>
        <reference name="content">
            <!-- add the block name to a parent -->
            <action method="insert">
                <block>catalog.product.related</block>
            </action>
            <!--
                Mage_Core_Block_Abstract::insert() accepts multiple arguments,
                but by default it will insert the added block at the beginning
                of the list of child blocks.
            -->
        </reference>
    </catalog_product_view>
</layout>

目录产品相关
目录产品相关

此时,您可以将更改还原为原始布局xml文件。

Hi Benmarks,谢谢您的回答。你绝对是对的。我需要使用local.xml,而不是修改xml文件。感谢分享如何做到这一点。但这对我如何将相关产品与价格一起放置而不是放在产品页面底部的问题没有帮助。(除了底部,它不会在任何地方显示)抱歉,我的脚本中有一个错误(缺少布局更新句柄
目录\产品\视图
)。local.xml中的指令在
catalog.xml
中的指令之后进行求值,因此块应该插入到内容区域中子项列表的开头。此外,请注意,可能存在一些JS/DOM假设(相关的TigKox更新中间形式的字段);测试表单在内容区域是否有效。感谢Benmarks,这是新年后的第二天,也许我今天有点慢:)它帮助我到目前为止,相关产品框现在显示在产品视图页面的顶部(并且使用正确的方式)。但我需要在元素的中间。我有:Product name Product short desc-Product price and buy buy(产品价格和购买)按钮-这里我想要相关的产品-Product long desc-你明白吗?啊,在这种情况下,你需要
插入()
(可能)到
Product.info
块,而不是
内容
块,你需要自定义模板。谢谢Benmarks,我想你已经帮了我很多,我需要对insert()进行更深入的理解。因为在我看来,内容块是一个引用,而product.info是一个块。但我真的很感激你的帮助。谢谢你给我指明了正确的方向。