【问题标题】:Magento currency switch displaying incorrect currency in footer, but displays correct in headerMagento 货币开关在页脚中显示不正确的货币,但在页眉中显示正确
【发布时间】:2014-05-08 22:23:42
【问题描述】:

我在 Magento 的货币下拉开关中遇到了一个奇怪的问题。它在页眉中显示并正常工作,但页脚中的显示不正确。它会正确更改货币,因为当我在页脚中切换时,页眉中的货币会发生变化,但页脚下拉菜单显示错误的货币。如果我选择 EUR,则会显示 GBP,如果我选择 GBP,则会显示 EUR!

我在 /directory(与 currency_top.phtml 相同的位置)中创建了 currency_footer.phtml,并复制了代码,其中包含它的 div 类的唯一更改。以下是 currency_footer.phtml 中的代码:

<?php
/**
 * Currency switcher
 *
 * @see Mage_Directory_Block_Currency
 */
?>
<?php if($this->getCurrencyCount()>1): ?>
<div class="tm_footer_currency">
<label class="btn"><?php echo $this->__('Currency:') ?></label>
    <select name="currency" title="<?php echo $this->__('Currency') ?>" onchange="setLocation(this.value)">
    <?php foreach ($this->getCurrencies() as $_code => $_name): ?>
        <option value="<?php echo $this->getSwitchCurrencyUrl($_code) ?>"<?php if($_code==$this->getCurrentCurrencyCode()): ?> selected="selected"<?php endif; ?>>
            <?php echo $_code ?>
        </option>
    <?php endforeach; ?>
    </select>

</div>
<?php endif; ?>

在我的 xml 文档中,我在页脚中添加了块:

    <reference name="footer"><!-- To ADD In Footer -->
        <block type="newsletter/subscribe" name="footer.newsletter" template="newsletter/subscribe.phtml"/>
        <block type="directory/currency" name="currency_end" as="currency_end" template="directory/currency_footer.phtml"/>
    </reference>  

然后在footer.phtml中:

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

我尝试为块使用不同的名称,清除缓存并重新索引数据,但我尝试过的没有任何效果。

任何想法为什么它会显示不正确,但仍然可以正常工作?

另一个可能与此无关的问题,我将与朋友分享页面更改为弹出窗口,当我关闭弹出窗口时,标题中的货币下拉菜单重复!

【问题讨论】:

    标签: php magento drop-down-menu currency


    【解决方案1】:

    您需要将代码放入&lt;reference&gt;标签中,然后您将在footer.phtml中调用?php echo $this->getChildHtml('currency_end') ?>

    这里是代码

    <reference name="footer">
    <block type="directory/currency" name="currency_end" as="currency_end" 
    template="directory/currency_footer.phtml"/>
    </reference>
    

    或者,

    在其他过程中,您 would not need xml 代码并只需调用 below code in footer.phtml 这里的代码是

        <?php echo $this->getLayout()->createBlock('directory/currency')
    ->setTemplate('directory/currency_footer.phtml')->toHtml(); ?>
    

    【讨论】:

    • 感谢您的回复!抱歉,我没有说清楚,我已将代码放在参考中,并且该块正在显示,但它无法正常工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-30
    • 2020-05-13
    • 2011-03-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多