2014-05-08 71 views
0

我遇到了Magento中货币下拉开关的一个奇怪问题。它在页眉中正确显示并正常工作,但页脚中的显示不正确。它正确更改货币,因为标题中的标题更改为在页脚中切换时,但页脚下拉菜单显示错误的货币。如果我选择欧元,英镑显示,如果我选择英镑,欧元显示!Magento货币开关在页脚中显示不正确的货币,但在标题中显示正确

I /目录(同一位置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') ?> 

我已经尝试使用不同名称的块,清除缓存&重新索引的数据,但没有我试过的作品。

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

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

回答

0

你需要把代码<reference>标签之后,你将调用< ?php echo $this->getChildHtml('currency_end') ?>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(); ?> 
+0

感谢您的回复!对不起,我不清楚,我已经把代码放在参考中,块显示出来,但它不能正常工作。 – Tamsin