【问题标题】:magento unsetChild breadcrumbs inside product view page through local.xml filemagento unsetChild 面包屑在产品视图页面内通过 local.xml 文件
【发布时间】:2016-04-04 20:23:19
【问题描述】:

我不想删除全局级别的所有面包屑,我只想unsetChild 产品视图页面内的面包屑。

以下是我的代码,但它不起作用

<catalog_product_view>
    <reference name="root">
        <action method="unsetChild">
            <child>breadcrumbs</child>
        </action>   
    </reference>
</catalog_product_view> 

我也尝试了以下方法,但也没有运气

<name>breadcrumbs</name> 

我注意到还有一件事,在我的 catalog.xml 文件中,产品视图的布局根本不调用面包屑块。以下是代码。如果有其他句柄调用面包屑块,它会在哪里?

<catalog_product_view translate="label">
    <label>Catalog Product View (Any)</label>
    <!-- Mage_Catalog -->
    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    </reference>
    <reference name="head">
        <action method="addJs"><script>varien/product.js</script></action>
        <action method="addJs"><script>varien/configurable.js</script></action>

        <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action>
        <action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
        <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
    </reference>
    <reference name="content">
        <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
            <!--
            <action method="addReviewSummaryTemplate"><type>default</type><template>review/helper/summary.phtml</template></action>
            <action method="addReviewSummaryTemplate"><type>short</type><template>review/helper/summary_short.phtml</template></action>
            <action method="addReviewSummaryTemplate"><type>...</type><template>...</template></action>
            -->
            <block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>
            <block type="core/text_list" name="alert.urls" as="alert_urls" translate="label">
                <label>Alert Urls</label>
            </block>

            <action method="setTierPriceTemplate"><template>catalog/product/view/tierprices.phtml</template></action>

            <block type="catalog/product_view_tabs" name="product.info.tabs" as="info_tabs" template="catalog/product/view/tabs.phtml" >
                <action method="addTab" translate="title" module="catalog"><alias>description</alias><title>Product Description</title><block>catalog/product_view_description</block><template>catalog/product/view/description.phtml</template></action>
                <!--<action method="addTab" translate="title" module="catalog"><alias>upsell_products</alias><title>We Also Recommend</title><block>catalog/product_list_upsell</block><template>catalog/product/list/upsell.phtml</template></action>-->
                <action method="addTab" translate="title" module="catalog"><alias>additional</alias><title>Additional Information</title><block>catalog/product_view_attributes</block><template>catalog/product/view/attributes.phtml</template></action>
                <!--<action method="addTab" translate="title" module="catalog"><alias>related_products</alias><title>Related Products</title><block>catalog/product_list_related</block><template>catalog/product/list/related.phtml</template></action>-->
                <block type="review/form" name="product.review.form" as="review_form"/>                                        
                <action method="addTab" translate="title" module="review">
                     <alias>product_additional_data</alias>
                     <title>Reviews</title>
                     <block>review/product_view_list</block>
                     <template>review/product/view/list_tab.phtml</template>
                </action>
            </block>

            <block type="catalog/product_list_upsell" name="product.info.upsell" as="upsell_products" template="catalog/product/list/upsell.phtml">
                <action method="setColumnCount"><columns>4</columns></action>
                <action method="setItemLimit"><type>upsell</type><limit>4</limit></action>
            </block>
            <block type="catalog/product_list_related" name="magentothem.relatedslider" as="related_slider" template="magentothem/relatedslider/relatedslider.phtml"/>
            <block type="catalog/product_view_additional" name="product.info.additional" as="product_additional_data" />
            <block type="catalog/product_view_description" name="product.description" as="description" template="catalog/product/view/description.phtml">
                <action method="addToParentGroup"><group>detailed_info</group></action>
            </block>
            <block type="catalog/product_view_attributes" name="product.attributes" as="additional" template="catalog/product/view/attributes.phtml">
                <action method="addToParentGroup"><group>detailed_info</group></action>
            </block>

            <block type="catalog/product_view" name="product.info.addto" as="addto" template="catalog/product/view/addto.phtml"/>
            <block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"/>

            <block type="core/text_list" name="product.info.extrahint" as="extrahint" translate="label">
                <label>Product View Extra Hint</label>
            </block>

            <block type="catalog/product_view" name="product.info.options.wrapper" as="product_options_wrapper" template="catalog/product/view/options/wrapper.phtml" translate="label">
                <label>Info Column Options Wrapper</label>
                <block type="core/template" name="options_js" template="catalog/product/view/options/js.phtml"/>
                <block type="catalog/product_view_options" name="product.info.options" as="product_options" template="catalog/product/view/options.phtml">
                    <action method="addOptionRenderer"><type>text</type><block>catalog/product_view_options_type_text</block><template>catalog/product/view/options/type/text.phtml</template></action>
                    <action method="addOptionRenderer"><type>file</type><block>catalog/product_view_options_type_file</block><template>catalog/product/view/options/type/file.phtml</template></action>
                    <action method="addOptionRenderer"><type>select</type><block>catalog/product_view_options_type_select</block><template>catalog/product/view/options/type/select.phtml</template></action>
                    <action method="addOptionRenderer"><type>date</type><block>catalog/product_view_options_type_date</block><template>catalog/product/view/options/type/date.phtml</template></action>
            </block>

                    <block type="core/html_calendar" name="html_calendar" as="html_calendar" template="page/js/calendar.phtml"/>
                </block>

            <block type="catalog/product_view" name="product.info.options.wrapper.bottom" as="product_options_wrapper_bottom" template="catalog/product/view/options/wrapper/bottom.phtml" translate="label">
                <label>Bottom Block Options Wrapper</label>
                <action method="append"><block>product.info.addtocart</block></action>
                <action method="append"><block>product.info.addto</block></action>
            </block>

            <block type="core/template_facade" name="product.info.container1" as="container1">
                <action method="setDataByKey"><key>alias_in_layout</key><value>container1</value></action>
                <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action>
                <action method="append"><block>product.info.options.wrapper</block></action>
                <action method="append"><block>product.info.options.wrapper.bottom</block></action>
            </block>
            <block type="core/template_facade" name="product.info.container2" as="container2">
                <action method="setDataByKey"><key>alias_in_layout</key><value>container2</value></action>
                <action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action>
                <action method="append"><block>product.info.options.wrapper</block></action>
                <action method="append"><block>product.info.options.wrapper.bottom</block></action>
            </block>
            <action method="unsetCallChild"><child>container1</child><call>ifEquals</call><if>0</if><key>alias_in_layout</key><key>options_container</key></action>
            <action method="unsetCallChild"><child>container2</child><call>ifEquals</call><if>0</if><key>alias_in_layout</key><key>options_container</key></action>
        </block>
    </reference>
   <!--  <reference name="right">
        <block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
    </reference> -->

    <!-- <reference name="right">
        <block type="catalog/product_list_related" name="magentothem.relatedslider" before="-" template="magentothem/relatedslider/relatedslider.phtml"/>
        <block type="catalog/product_compare_sidebar"  name="catalog.compare.sidebar" template="catalog/product/compare/sidebar.phtml"/>
        <block type="tag/popular" name="tags_popular" after="magentothem.relatedslider" template="tag/popular.phtml"/>
        <block type="cms/block" name="banner_right" after="-">
            <action method="setBlockId"><block_id>banner_right</block_id></action>
        </block>
        <remove name="sale.reorder.sidebar"/> 
    </reference> -->

    <remove name="right.poll"/>
    <remove name="cart_sidebar"/>
</catalog_product_view>

【问题讨论】:

  • 我刚刚发现在我的 1column.phtml 中有一个 getChildHtml('breadcrumbs') ?>,在这种情况下我只是将其删除吗?
  • 在这种情况下,它将从所有使用1column.phtml 作为布局的页面中删除

标签: xml magento layout breadcrumbs


【解决方案1】:

以下代码适用于 magento 1.9.2。将此代码放入您的local.xml

    <catalog_product_view>
        <reference name="root">
            <remove name="breadcrumbs"/>
        </reference>
    </catalog_product_view>

【讨论】:

  • 不删除所有面包屑,检查类别页面。
  • 我也有 1.9.2,但它对我不起作用。可能是主题文件的问题?
  • 也许吧。您使用的是自定义主题还是默认的 magento 主题?
【解决方案2】:

在布局的local.xml中使用以下代码

<catalog_category_view>
    <reference name="root">
        <remove name="breadcrumbs"/>
    </reference>
</catalog_category_view>

catalog_category_view 用于所有类别页面。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多