2014-05-08 68 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