我在Magento中遇到了一个奇怪的货币下拉开关问题。它在页眉中正确显示和工作,但在页脚中的显示不正确。它正确地改变了货币,因为当我在页脚中切换它时,页眉中的货币发生了变化,但是页脚下拉菜单显示了错误的货币。如果我选择欧元,显示英镑,如果我选择英镑,显示欧元!
我创建currency_footer。/目录内的phtml(与currency_top.phtml相同的位置),我复制了代码,其中包含的div类只有一个变化。以下是currency_footer. php中的代码:
<?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. php:
<?php echo $this->getChildHtml('currency_end') ?>
我已经尝试使用不同的名称块,清除缓存&重新索引数据,但我试过的都不起作用。
知道为什么它会显示不正确,但仍然工作正常吗?
另一个可能与它无关的问题,我将与朋友分享页面更改为弹出窗口,当我关闭弹出窗口时,标题中的货币下拉菜单重复!
您需要在<reference>
标签中放入代码,然后调用<?php echo $this->getChildHtml('currency_end') ?>
in=" footer.phtml
=">
这里的代码
<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(); ?>