通过xml或phtml删除Magento块

时间:2014-06-13 07:15:57

标签: magento magento-1.9

我开始使用magento主题开发,并编写了我的local.xml以删除下面的2个块。

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="header">
            <remove name="currency" /><!--removes currency selector--> 
            <remove name="store_language" /><!--removes store language --> 
        </reference>
    </default>
</layout>

这样可行,但模板header.phtml的块包含在现在不需要的div中。见下文:

<div class="header-language-background">
    <div class="header-language-container">
        <div class="store-language-container">
            <?php echo $this->getChildHtml('store_language') ?>
        </div>

        <?php echo $this->getChildHtml('currency_switcher') ?>

        <p class="welcome-msg"><?php echo $this->getChildHtml('welcome') ?> <?php echo $this->getAdditionalHtml() ?></p>
    </div>
</div>

我的问题是,我可以从模板文件中删除该部分而不是删除块吗?如果块在xml文件中但没有在任何模板phtml文件中调用,这会影响到什么吗?

谢谢:)

2 个答案:

答案 0 :(得分:0)

  • 如果您需要删除的HTML被引用为XML块,那么最好使用<remove>节点将其从XML中删除。
  • 如果要删除的HTML未被引用为XML块,则直接从模板中删除它是唯一的解决方案。当然,您应该根据自己的主题编辑模板,而不是基础模板中的模板。

答案 1 :(得分:0)

如果删除默认商店语言,则只需在header.phtml中注释掉。 像这样。

<?php echo $this->getChildHtml('store_language') ?>

注释...

<?php **//**echo $this->getChildHtml('store_language') ?>
相关问题