Magento:从布局中取消第二/第三级块?

use*_*462 2 magento

如何从布局中取消子/孙块?

例如来自

<reference name="content">
            <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
                   <block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>
            </block>
</reference>
Run Code Online (Sandbox Code Playgroud)

我可以删除整个

<reference name="content">
    <action method="unsetChild"><name>product.info</name></action>
</reference>
Run Code Online (Sandbox Code Playgroud)

但我想从"product.info"中删除name ="product.info.media",而不是整个product.info.

这该怎么做 ?

Vin*_*nai 5

要将子块从一个父项移动到另一个父项,请引用直接父项,在其上调用unsetChild,然后使用insert方法将块实例作为子项分配给另一个父项.

<reference name="product.info">
    <!-- use the alias here -->
    <action method="unsetChild"><child>media</child></action>
</reference>
<reference name="new.parent">
    <!-- use the full block name here -->
    <action method="insert"><child>product.info.media</child></action>
</reference>
Run Code Online (Sandbox Code Playgroud)

不支持未出现的孙子块,我不认为那是愚蠢但明智的(因为你会在哪里停止 - unsetGrandGrandGrandChild()?).