Magento:xml块增加了一倍

时间:2011-12-13 13:56:32

标签: xml magento block

cms.xml具有默认值:

<default>
    <reference name="footer">
        <block type="cms/block" name="cms_footer_links" before="footer_links">
             <action method="setBlockId"><block_id>footer_links</block_id></action>
         </block>
     </reference>
</default>

我的local.xml包含以下内容:

<default>
     <reference name="footer">
             <remove name="store_switcher" />
             <remove name="footer_links" />

             <block type="page/html_wrapper" name="footer.links.wrapper" translate="label" before="-">
                <label>Footer Links Wrapper</label>
                <action method="setElementClass"><value>bottomLinks</value></action>

                <block type="cms/block" name="cms_footer_links">
                    <action method="setBlockId"><block_id>footer_links</block_id></action>
                </block>
             </block>

      </reference>
</default>

但在这种情况下,我获得了双倍的footer_links阻止。第一个是在页面静态块中,另一个包含在div.bottomLinks中。

如何解决这个问题?如何在没有cms.xml编辑的情况下只显示一个包装块?

2 个答案:

答案 0 :(得分:0)

您的remove-tag包含错误的块名称。它应该是<remove name="cms_footer_links" />而不是<remove name="footer_links" />

答案 1 :(得分:0)

在本地xml

中试试
<default>
....
</default>

<cms_index_index>
    <reference name="footer">
        <remove name="cms_footer_links" />
    </reference name>
</cms_index_index>

并在

<block type="cms/block" name="cms_footer_links">

您应该将名称更改为“cms_footer_another_links”。

嗯,我希望我的问题是对的。

更新1

默认部分随处可见。所以,如果我正确地理解你只想要一个块的单个实例。

尝试以下(local.xml):

<default>

    <reference name="footer">
        <action method="unsetChild"><name>cms_footer_links</name></action>

         <block type="page/html_wrapper" name="footer.links.wrapper" translate="label" before="-">
            <label>Footer Links Wrapper</label>
            <action method="setElementClass"><value>bottomLinks</value></action>

            <block type="cms/block" name="cms_footer_links"/>
         </block>
</default>

OR

<default>

    <reference name="footer">
        <remove name="cms_footer_links" />



         <block type="page/html_wrapper" name="footer.links.wrapper" translate="label" before="-">
            <label>Footer Links Wrapper</label>
            <action method="setElementClass"><value>bottomLinks</value></action>
            <block type="cms/block" name="cms_another_footer_links">
                <action method="setBlockId"><block_id>footer_links</block_id></action>
            </block>
         </block>
   </reference>
</default>