Magento xml 布局奇怪的行为
Magento xml layout strange behavior
我正在安装 1.9.3 Magento,尝试优化现有应用程序。
有一个自定义主题,它定义了自定义布局,我发现这里乱七八糟:到处都是重复的文件,核心行为完全荒谬的覆盖,所以我试图整理一切,一天后我成功了,除非对于最后一步中发生的一些非常奇怪的事情。
我有 2 个主要布局文件:local.xml and page.xml
,我想将它们合并到一个文件中。
一切正常,直到我将所有自定义头部行为(在单个部分中清理上传的资产),但一旦我合并自定义页面布局,一切都停止工作。
我的意思是:
page.xml
<layout version="0.1.0">
<default>
<label>All Pages</label>
<block type="page/html_head" name="head" as="head">
<action method="addJs"><script>prototype/prototype.js</script></action>
<action ..... more js and css.../>
</block>
<block...../>
</default>
<!-- Custom page layout handles -->
<page_empty ..../>
<page_one_column ..../>
<page_two_columns_left ..../>
....
</layout>
local.xml
还剩下什么
<layout>
<cms_index_index translate="label">
<label>CMS Home Page</label>
<reference name="head"></reference>
</cms_index_index>
<cms_page>
<reference name="content">
<action method="unsetChild">
<alias>cms.wrapper</alias>
</action>
<block type="cms/page" name="cms_page"/>
</reference>
</cms_page>
<catalog_product_view .../>
<catalog_category_layered .../>
<catalog_category_default .../>
</layout>
当我尝试合并这两个布局时,问题就出现了:迷你购物车和搜索表单消失了,主页中的其他元素变得混乱和重复。
可能的原因是什么?自定义主题中的其他布局文件中没有其他影响主页或其他类似元素的重新定义。显然还有其他布局定义,但每个都有自己的作用。
我真的不知道还有什么地方可以搜索。
现在我可以将两个文件分开,一切正常。
编辑:
这是我清理过的旧 local.xml。
<?xml version="1.0"?>
<layout>
<default>
<!--CSS and JS Files-->
<reference name="head">
<!-- Modifiche per Casabiancheria-->
<action method="addItem"><type>skin_js</type><script>js/prodotto/product.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/prodotto/configurable.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/prodotto/calendar.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/prodotto/calendar-setup.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/modernizr.custom.min.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/selectivizr.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/matchMedia.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/matchMedia.addListener.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/enquire.js</script></action>
<!--
<action method="addItem"><type>skin_js</type><script>js/vendor/app.js</script></action>
-->
<action method="addItem"><type>skin_js</type><script>js/vendor/slideshow.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/imagesloaded.js</script></action>
<action method="removeItem"><type>skin_js</type><name>js/minicart.js</name></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/minicart.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/prodotto/jquery.elevateZoom-3.0.8.min.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/msrp.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/msrp_rwd.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/jquery.flexslider-min.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/main.js</script></action>
<action method="addItem"><type>skin_css</type><name>css/calendar-win2k-1.css</name></action>
</reference>
<remove name="footer_links"/>
<remove name="footer_links2"/>
</default>
<cms_index_index translate="label">
<label>CMS Home Page</label>
<reference name="head"></reference>
</cms_index_index>
<cms_page>
<reference name="content">
<action method="unsetChild">
<alias>cms.wrapper</alias>
</action>
<block type="cms/page" name="cms_page"/>
</reference>
</cms_page>
<!--Product View-->
<catalog_product_view>
<!--CSS and JS Files-->
<reference name="head">
</reference>
<reference name="content">
<!-- <block type="catalog/product_list_related" name="catalog.product.related" as="related_products" template="catalog/product/list/related2.phtml" />-->
<remove name="product.info.extrahint"/>
<remove name="product.reviews"/>
<block type="core/template" name="slider" template="catalog/product/list_session.phtml" />
</reference>
</catalog_product_view>
<catalog_category_layered>
<reference name="head">
<!-- Remove items which the RWD package is not dependent upon -->
<action method="removeItem"><type>skin_js</type><name>js/lib/jquery-1.10.2.min.js</name></action>
</reference>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
</reference>
<reference name="product_list">
<action method="setColumnCount"><count>3</count></action>
</reference>
</catalog_category_layered>
<catalog_category_default>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
</reference>
<reference name="product_list">
<action method="setColumnCount"><count>3</count></action>
</reference>
</catalog_category_default>
</layout>
编辑 2:这是我实际使用的 page.xml
的最终版本
<layout version="0.1.0">
<default translate="label" module="page">
<label>All Pages</label>
<block type="page/html" name="root" output="toHtml" template="page/3columns.phtml">
<block type="page/html_head" name="head" as="head">
<action method="addJs"><script>prototype/prototype.js</script></action>
<action method="addJs"><script>lib/jquery/jquery-1.10.2.min.js</script></action>
<action method="addJs"><script>lib/jquery/noconflict.js</script></action>
<action method="addJs"><script>lib/ccard.js</script></action>
<action method="addJs"><script>prototype/validation.js</script></action>
<action method="addJs"><script>scriptaculous/builder.js</script></action>
<action method="addJs"><script>scriptaculous/effects.js</script></action>
<action method="addJs"><script>scriptaculous/dragdrop.js</script></action>
<action method="addJs"><script>scriptaculous/controls.js</script></action>
<action method="addJs"><script>scriptaculous/slider.js</script></action>
<action method="addJs"><script>varien/js.js</script></action>
<action method="addJs"><script>varien/form.js</script></action>
<action method="addJs"><script>mage/translate.js</script></action>
<action method="addJs"><script>mage/cookies.js</script></action>
<block type="page/js_cookie" name="js_cookies" template="page/js/cookie.phtml"/>
<!-- Remove items which the RWD package is not dependent upon -->
<action method="removeItem"><type>skin_js</type><name>js/ie6.js</name></action>
<!-- Add vendor dependencies -->
<action method="addItem"><type>skin_js</type><name>js/lib/modernizr.custom.min.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/selectivizr.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/matchMedia.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/matchMedia.addListener.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/enquire.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/app.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/jquery.cycle2.min.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/jquery.cycle2.swipe.min.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/slideshow.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/imagesloaded.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/minicart.js</name></action>
<action method="addItem"><type>skin_js</type><script>js/msrp.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/msrp_rwd.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/jquery.flexslider-min.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/main.js</script></action>
<!-- Add stylesheets with no media queries for use in IE 8 and below -->
<action method="addItem"><type>skin_css</type><name>css/styles-ie8.css</name><params/><if><![CDATA[ (lte IE 8) & (!IEMobile)]]></if></action>
<action method="addItem"><type>skin_css</type><name>css/madisonisland-ie8.css</name><params/><if><![CDATA[ (lte IE 8) & (!IEMobile)]]></if></action>
<!-- Add stylesheets with media queries for use by modern browsers -->
<action method="addItem"><type>skin_css</type><name>css/fonts/roboto-condensed/stylesheet.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
<action method="addItem"><type>skin_css</type><name>css/styles.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
<action method="addItem"><type>skin_css</type><name>css/fonts/fontello3/css/fontello.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
<action method="addItem"><type>skin_css</type><name>css/madisonisland.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
<action method="addItem"><type>skin_css</type><name>css/flexslider.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
<!-- Sets viewport meta tag using text block -->
<block type="core/text" name="head.viewport">
<action method="setText"><text><![CDATA[<meta name="viewport" content="initial-scale=1.0, width=device-width" />]]> </text></action>
</block>
</block>
<block type="core/text_list" name="after_body_start" as="after_body_start" translate="label">
<label>Page Top</label>
</block>
<block type="page/html_notices" name="global_notices" as="global_notices" template="page/html/notices.phtml" />
<block type="page/html_header" name="header" as="header">
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
<label>Navigation Bar</label>
<block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml">
<block type="page/html_topmenu_renderer" name="catalog.topnav.renderer" template="page/html/topmenu/renderer.phtml"/>
</block>
</block>
<block type="page/html_wrapper" name="top.container" as="topContainer" translate="label">
<label>Page Header</label>
<action method="setElementClass"><value>top-container</value></action>
</block>
<block type="page/html_welcome" name="welcome" as="welcome"/>
</block>
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
<block type="core/text_list" name="left_first" as="left_first" translate="label">
<label>Left Column First (shows above main column on smaller screens)</label>
</block>
<block type="core/text_list" name="left" as="left" translate="label">
<label>Left Column</label>
</block>
<block type="core/messages" name="global_messages" as="global_messages"/>
<block type="core/messages" name="messages" as="messages"/>
<block type="core/text_list" name="content" as="content" translate="label">
<label>Main Content Area</label>
</block>
<block type="core/text_list" name="right" as="right" translate="label">
<label>Right Column</label>
</block>
<block type="page/html_wrapper" name="footer.before" as="footer_before" translate="label">
<label>Page Footer</label>
<action method="setElementClass"><value>footer-before-container</value></action>
</block>
<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label">
<label>Page Footer</label>
<action method="setElementClass"><value>bottom-container</value></action>
</block>
<block type="page/switch" name="store_switcher" as="store_switcher" after="*" template="page/switch/stores.phtml"/>
<block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml">
<action method="setTitle"><title>Quick Links</title></action>
</block>
<block type="page/template_links" name="footer_links2" as="footer_links2" template="page/template/links.phtml">
<action method="setTitle"><title>Account</title></action>
</block>
<!-- This static block can be created and populated in admin. The footer_links cms block can be used as a starting point. -->
<!--<block type="cms/block" name="footer_social_links">
<action method="setBlockId"><block_id>footer_social_links</block_id></action>
</block>-->
</block>
<block type="core/text_list" name="before_body_end" as="before_body_end" translate="label">
<label>Page Bottom</label>
<block type="page/html_cookieNotice" name="global_cookie_notice" as ="global_cookie_notice" template="page/html/cookienotice.phtml" before="-" />
</block>
</block>
<remove name="footer_links"/>
<remove name="footer_links2"/>
<block type="core/profiler" output="toHtml" name="core_profiler"/>
</default>
<catalog_product_view>
<!--CSS and JS Files-->
<reference name="head">
</reference>
<reference name="content">
<remove name="product.info.extrahint"/>
<remove name="product.reviews"/>
<block type="core/template" name="slider" template="catalog/product/list_session.phtml" />
</reference>
</catalog_product_view>
<catalog_category_layered>
<reference name="head"></reference>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
</reference>
<reference name="product_list">
<action method="setColumnCount"><count>3</count></action>
</reference>
</catalog_category_layered>
<catalog_category_default>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
</reference>
<reference name="product_list">
<action method="setColumnCount"><count>3</count></action>
</reference>
</catalog_category_default>
</layout>
为什么还要为 cms_index_index
句柄定义头部引用?
请提供有关清理的更多背景信息并显示完整文件。与原始 local.xml 的差异将帮助很多
您要将它们合并到什么文件中?我假设您正在将所有内容移至 local.xml
并从您的主题中删除 page.xml
文件?
这个问题是 local.xml
是最后加载的,因此当您替换 page.xml
中的块时,对 page.xml
的任何更新都将丢失。
方法如下:
page.xml
在 catalog.xml
和 checkout.xml
之前加载。目录和结帐将额外的块添加到 header(例如 mini-cart 和搜索表单)。但是由于 local.xml
是最后加载的,因此之前添加到页面 xml 的任何块,例如 catalog.xml
和 checkout.xml
,都会在此过程中丢失。
您需要做的是参考您需要更改的块,而不是替换它们。所以如果你需要在头部添加一个css文件,你这样做:
<default>
<reference name="head">
<!-- add blocks and actions here -->
</reference>
</default>
您需要区分默认修改和自定义修改,并通过引用将这些修改移至 local.xml
。然后你可以从你的主题中删除 page.xml
。
或者...您可以将代码分开。
我正在安装 1.9.3 Magento,尝试优化现有应用程序。
有一个自定义主题,它定义了自定义布局,我发现这里乱七八糟:到处都是重复的文件,核心行为完全荒谬的覆盖,所以我试图整理一切,一天后我成功了,除非对于最后一步中发生的一些非常奇怪的事情。
我有 2 个主要布局文件:local.xml and page.xml
,我想将它们合并到一个文件中。
一切正常,直到我将所有自定义头部行为(在单个部分中清理上传的资产),但一旦我合并自定义页面布局,一切都停止工作。
我的意思是:
page.xml
<layout version="0.1.0">
<default>
<label>All Pages</label>
<block type="page/html_head" name="head" as="head">
<action method="addJs"><script>prototype/prototype.js</script></action>
<action ..... more js and css.../>
</block>
<block...../>
</default>
<!-- Custom page layout handles -->
<page_empty ..../>
<page_one_column ..../>
<page_two_columns_left ..../>
....
</layout>
local.xml
还剩下什么<layout>
<cms_index_index translate="label">
<label>CMS Home Page</label>
<reference name="head"></reference>
</cms_index_index>
<cms_page>
<reference name="content">
<action method="unsetChild">
<alias>cms.wrapper</alias>
</action>
<block type="cms/page" name="cms_page"/>
</reference>
</cms_page>
<catalog_product_view .../>
<catalog_category_layered .../>
<catalog_category_default .../>
</layout>
当我尝试合并这两个布局时,问题就出现了:迷你购物车和搜索表单消失了,主页中的其他元素变得混乱和重复。
可能的原因是什么?自定义主题中的其他布局文件中没有其他影响主页或其他类似元素的重新定义。显然还有其他布局定义,但每个都有自己的作用。 我真的不知道还有什么地方可以搜索。 现在我可以将两个文件分开,一切正常。
编辑: 这是我清理过的旧 local.xml。
<?xml version="1.0"?>
<layout>
<default>
<!--CSS and JS Files-->
<reference name="head">
<!-- Modifiche per Casabiancheria-->
<action method="addItem"><type>skin_js</type><script>js/prodotto/product.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/prodotto/configurable.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/prodotto/calendar.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/prodotto/calendar-setup.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/modernizr.custom.min.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/selectivizr.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/matchMedia.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/matchMedia.addListener.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/enquire.js</script></action>
<!--
<action method="addItem"><type>skin_js</type><script>js/vendor/app.js</script></action>
-->
<action method="addItem"><type>skin_js</type><script>js/vendor/slideshow.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/imagesloaded.js</script></action>
<action method="removeItem"><type>skin_js</type><name>js/minicart.js</name></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/minicart.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/prodotto/jquery.elevateZoom-3.0.8.min.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/msrp.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/vendor/msrp_rwd.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/jquery.flexslider-min.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/main.js</script></action>
<action method="addItem"><type>skin_css</type><name>css/calendar-win2k-1.css</name></action>
</reference>
<remove name="footer_links"/>
<remove name="footer_links2"/>
</default>
<cms_index_index translate="label">
<label>CMS Home Page</label>
<reference name="head"></reference>
</cms_index_index>
<cms_page>
<reference name="content">
<action method="unsetChild">
<alias>cms.wrapper</alias>
</action>
<block type="cms/page" name="cms_page"/>
</reference>
</cms_page>
<!--Product View-->
<catalog_product_view>
<!--CSS and JS Files-->
<reference name="head">
</reference>
<reference name="content">
<!-- <block type="catalog/product_list_related" name="catalog.product.related" as="related_products" template="catalog/product/list/related2.phtml" />-->
<remove name="product.info.extrahint"/>
<remove name="product.reviews"/>
<block type="core/template" name="slider" template="catalog/product/list_session.phtml" />
</reference>
</catalog_product_view>
<catalog_category_layered>
<reference name="head">
<!-- Remove items which the RWD package is not dependent upon -->
<action method="removeItem"><type>skin_js</type><name>js/lib/jquery-1.10.2.min.js</name></action>
</reference>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
</reference>
<reference name="product_list">
<action method="setColumnCount"><count>3</count></action>
</reference>
</catalog_category_layered>
<catalog_category_default>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
</reference>
<reference name="product_list">
<action method="setColumnCount"><count>3</count></action>
</reference>
</catalog_category_default>
</layout>
编辑 2:这是我实际使用的 page.xml
的最终版本<layout version="0.1.0">
<default translate="label" module="page">
<label>All Pages</label>
<block type="page/html" name="root" output="toHtml" template="page/3columns.phtml">
<block type="page/html_head" name="head" as="head">
<action method="addJs"><script>prototype/prototype.js</script></action>
<action method="addJs"><script>lib/jquery/jquery-1.10.2.min.js</script></action>
<action method="addJs"><script>lib/jquery/noconflict.js</script></action>
<action method="addJs"><script>lib/ccard.js</script></action>
<action method="addJs"><script>prototype/validation.js</script></action>
<action method="addJs"><script>scriptaculous/builder.js</script></action>
<action method="addJs"><script>scriptaculous/effects.js</script></action>
<action method="addJs"><script>scriptaculous/dragdrop.js</script></action>
<action method="addJs"><script>scriptaculous/controls.js</script></action>
<action method="addJs"><script>scriptaculous/slider.js</script></action>
<action method="addJs"><script>varien/js.js</script></action>
<action method="addJs"><script>varien/form.js</script></action>
<action method="addJs"><script>mage/translate.js</script></action>
<action method="addJs"><script>mage/cookies.js</script></action>
<block type="page/js_cookie" name="js_cookies" template="page/js/cookie.phtml"/>
<!-- Remove items which the RWD package is not dependent upon -->
<action method="removeItem"><type>skin_js</type><name>js/ie6.js</name></action>
<!-- Add vendor dependencies -->
<action method="addItem"><type>skin_js</type><name>js/lib/modernizr.custom.min.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/selectivizr.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/matchMedia.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/matchMedia.addListener.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/enquire.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/app.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/jquery.cycle2.min.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/jquery.cycle2.swipe.min.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/slideshow.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/lib/imagesloaded.js</name></action>
<action method="addItem"><type>skin_js</type><name>js/minicart.js</name></action>
<action method="addItem"><type>skin_js</type><script>js/msrp.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/msrp_rwd.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/jquery.flexslider-min.js</script></action>
<action method="addItem"><type>skin_js</type><script>js/main.js</script></action>
<!-- Add stylesheets with no media queries for use in IE 8 and below -->
<action method="addItem"><type>skin_css</type><name>css/styles-ie8.css</name><params/><if><![CDATA[ (lte IE 8) & (!IEMobile)]]></if></action>
<action method="addItem"><type>skin_css</type><name>css/madisonisland-ie8.css</name><params/><if><![CDATA[ (lte IE 8) & (!IEMobile)]]></if></action>
<!-- Add stylesheets with media queries for use by modern browsers -->
<action method="addItem"><type>skin_css</type><name>css/fonts/roboto-condensed/stylesheet.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
<action method="addItem"><type>skin_css</type><name>css/styles.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
<action method="addItem"><type>skin_css</type><name>css/fonts/fontello3/css/fontello.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
<action method="addItem"><type>skin_css</type><name>css/madisonisland.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
<action method="addItem"><type>skin_css</type><name>css/flexslider.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
<!-- Sets viewport meta tag using text block -->
<block type="core/text" name="head.viewport">
<action method="setText"><text><![CDATA[<meta name="viewport" content="initial-scale=1.0, width=device-width" />]]> </text></action>
</block>
</block>
<block type="core/text_list" name="after_body_start" as="after_body_start" translate="label">
<label>Page Top</label>
</block>
<block type="page/html_notices" name="global_notices" as="global_notices" template="page/html/notices.phtml" />
<block type="page/html_header" name="header" as="header">
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
<label>Navigation Bar</label>
<block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml">
<block type="page/html_topmenu_renderer" name="catalog.topnav.renderer" template="page/html/topmenu/renderer.phtml"/>
</block>
</block>
<block type="page/html_wrapper" name="top.container" as="topContainer" translate="label">
<label>Page Header</label>
<action method="setElementClass"><value>top-container</value></action>
</block>
<block type="page/html_welcome" name="welcome" as="welcome"/>
</block>
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
<block type="core/text_list" name="left_first" as="left_first" translate="label">
<label>Left Column First (shows above main column on smaller screens)</label>
</block>
<block type="core/text_list" name="left" as="left" translate="label">
<label>Left Column</label>
</block>
<block type="core/messages" name="global_messages" as="global_messages"/>
<block type="core/messages" name="messages" as="messages"/>
<block type="core/text_list" name="content" as="content" translate="label">
<label>Main Content Area</label>
</block>
<block type="core/text_list" name="right" as="right" translate="label">
<label>Right Column</label>
</block>
<block type="page/html_wrapper" name="footer.before" as="footer_before" translate="label">
<label>Page Footer</label>
<action method="setElementClass"><value>footer-before-container</value></action>
</block>
<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<block type="page/html_wrapper" name="bottom.container" as="bottomContainer" translate="label">
<label>Page Footer</label>
<action method="setElementClass"><value>bottom-container</value></action>
</block>
<block type="page/switch" name="store_switcher" as="store_switcher" after="*" template="page/switch/stores.phtml"/>
<block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml">
<action method="setTitle"><title>Quick Links</title></action>
</block>
<block type="page/template_links" name="footer_links2" as="footer_links2" template="page/template/links.phtml">
<action method="setTitle"><title>Account</title></action>
</block>
<!-- This static block can be created and populated in admin. The footer_links cms block can be used as a starting point. -->
<!--<block type="cms/block" name="footer_social_links">
<action method="setBlockId"><block_id>footer_social_links</block_id></action>
</block>-->
</block>
<block type="core/text_list" name="before_body_end" as="before_body_end" translate="label">
<label>Page Bottom</label>
<block type="page/html_cookieNotice" name="global_cookie_notice" as ="global_cookie_notice" template="page/html/cookienotice.phtml" before="-" />
</block>
</block>
<remove name="footer_links"/>
<remove name="footer_links2"/>
<block type="core/profiler" output="toHtml" name="core_profiler"/>
</default>
<catalog_product_view>
<!--CSS and JS Files-->
<reference name="head">
</reference>
<reference name="content">
<remove name="product.info.extrahint"/>
<remove name="product.reviews"/>
<block type="core/template" name="slider" template="catalog/product/list_session.phtml" />
</reference>
</catalog_product_view>
<catalog_category_layered>
<reference name="head"></reference>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
</reference>
<reference name="product_list">
<action method="setColumnCount"><count>3</count></action>
</reference>
</catalog_category_layered>
<catalog_category_default>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
</reference>
<reference name="product_list">
<action method="setColumnCount"><count>3</count></action>
</reference>
</catalog_category_default>
</layout>
为什么还要为 cms_index_index
句柄定义头部引用?
请提供有关清理的更多背景信息并显示完整文件。与原始 local.xml 的差异将帮助很多
您要将它们合并到什么文件中?我假设您正在将所有内容移至 local.xml
并从您的主题中删除 page.xml
文件?
这个问题是 local.xml
是最后加载的,因此当您替换 page.xml
中的块时,对 page.xml
的任何更新都将丢失。
方法如下:
page.xml
在 catalog.xml
和 checkout.xml
之前加载。目录和结帐将额外的块添加到 header(例如 mini-cart 和搜索表单)。但是由于 local.xml
是最后加载的,因此之前添加到页面 xml 的任何块,例如 catalog.xml
和 checkout.xml
,都会在此过程中丢失。
您需要做的是参考您需要更改的块,而不是替换它们。所以如果你需要在头部添加一个css文件,你这样做:
<default>
<reference name="head">
<!-- add blocks and actions here -->
</reference>
</default>
您需要区分默认修改和自定义修改,并通过引用将这些修改移至 local.xml
。然后你可以从你的主题中删除 page.xml
。
或者...您可以将代码分开。