Magento:xml 块加倍

发布于 2024-12-20 21:31:53 字数 1263 浏览 0 评论 0原文

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 的情况下仅显示一个包装块?

cms.xml has default value:

<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>

My local.xml has follow content:

<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>

But in this case I get doubled footer_links block. The first one is as it is in a page static block, the other one is wrapped into div.bottomLinks.

How to fix this? How to show only one wrapped block without cms.xml editing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜唯美灬不弃 2024-12-27 21:31:53

在本地 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

默认部分已加载到各处。所以如果我正确理解你只需要 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>

<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>

Try this in local xml

<default>
....
</default>

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

And in

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

You should change name to something like "cms_footer_another_links".

Well I hope I got your question right.

UPDATE 1

default section is loaded everywhere. So IF I correctly understood u want only 1 single instance of block.

Try the following(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>
无力看清 2024-12-27 21:31:53

您的删除标签包含错误的块名称。它应该是 而不是

Your remove-tag contains the wrong block name. It should be <remove name="cms_footer_links" /> instead of <remove name="footer_links" />.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文