在我的項目中,我必須以兩種語言顯示網店。 默認情況下,您可以選擇下面的代碼語言:Magento更改語言選擇器
應用程序/設計/前端/基/默認/模板/頁/開關/ language.phtml
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?></label>
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>
這當然displaya選擇框選項是所有的語言。
但是我想改變它,使它成爲單獨的鏈接。 我只是不知道如何做到這一點。
這是我現在有。
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<?php foreach ($this->getStores() as $_lang):?>
<a href="" title=""><?php echo $this->htmlEscape($_lang->getName()) ?></a>
<?php endforeach;?>
</div>
<?php endif; ?>
PS:我沒有默認的Magento代碼改變這一點。我在app/design/frontend/default/projectname/template/page/switch/language.phtml中工作。
所以我是自己用這個代碼得到這個工作:
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<?php foreach ($this->getStores() as $_lang):?>
<a href="<?php echo Mage::getUrl() . '?___store=' . $_lang->getId()?>" title=""><?php echo $this->htmlEscape($_lang->getName()) ?></a>
<?php endforeach;?>
</div>
<?php endif; ?>
但現在當我切換語言。它重定向到主頁。 我發現我應該使用:
$_lang->getCurrentUrl()
但我不知道在哪裏把這個在我的代碼。
在我的magento版本(最新的企業版)中,它已經是一個包含單獨鏈接的列表。我不確定這個版本有哪些變化,也許你可以採用更新的magento版本? –
嗯,我有最新的.. 奇怪:P – Weszzz7