2015-03-02 68 views
1

我们的商店有两个商店视图。一个是荷兰语,另一个是英语。我们使用下面的代码来显示选择视图的标志。从Magento中的语言选择器隐藏当前标志

<?php if(count($this->getStores()) > 1): ?> 
<div class="form-language"> 
     <div class="langs-wrapper"> 
    <?php foreach ($this->getStores() as $_lang): ?> 
     <?php $selected = $_lang->getId() == $this->getCurrentStoreId() ?> 
     <a class="lang-flag<?php $selected && print ' selected' ?>" href="<?php echo $_lang->getCurrentUrl() ?>"> 
      <img src="<?php echo $this->getSkinUrl('images/flags/' . $_lang->getCode() . '.png');?>" alt="<?php echo $this->htmlEscape($_lang->getName()) ?>"> 
     </a> 
    <?php endforeach ?> 
</div> 
</div> 
<?php endif ?> 

现在我们想隐藏当前语言的标志。因为你不需要看到这些。我们如何创建这个?

回答

0

试试这个希望它会做你的工作

<?php if(count($this->getStores()) > 1): ?> 
<div class="form-language"> 
     <div class="langs-wrapper"> 
    <?php foreach ($this->getStores() as $_lang): ?> 
     <?php $selected = $_lang->getId() == $this->getCurrentStoreId() ?> 

<?php if(Mage::app()->getLocale()->getLocaleCode()==$_lang->getCode()):?> 
     <a class="lang-flag<?php $selected && print ' selected' ?>" href="<?php echo $_lang->getCurrentUrl() ?>"> 
      <img src="<?php echo $this->getSkinUrl('images/flags/' . $_lang->getCode() . '.png');?>" alt="<?php echo $this->htmlEscape($_lang->getName()) ?>"> 
     </a> 
     <?php endif ?> 
    <?php endforeach ?> 
</div> 
</div> 
<?php endif ?> 
+0

当我替换代码时,完整的站点消失。 – Sjoerd 2015-03-02 13:24:21

+0

现在试试我已编辑答案 – 2015-03-02 13:30:47

+0

我做了一些改动,请参阅下面的文章。谢谢你的帮助。 – Sjoerd 2015-03-02 14:23:50

0

我改变罗希特戈埃尔的代码:

<?php if(count($this->getStores()) > 1): ?> 
<div class="form-language"> 
     <div class="langs-wrapper"> 
    <?php foreach ($this->getStores() as $_lang): ?> 
     <?php $selected = $_lang->getId() == $this->getCurrentStoreId() ?> 

<?php if(Mage::app()->getLocale()->getLocaleCode() !=$_lang->getCode()):?> 
     <a class="lang-flag<?php $selected && print ' selected' ?>" href="<?php echo $_lang->getCurrentUrl() ?>"> 
      <img src="<?php echo $this->getSkinUrl('images/flags/' . $_lang->getCode() . '.png');?>" class="<?php echo $this->htmlEscape($_lang->getName()) ?>" alt="<?php echo $this->htmlEscape($_lang->getName()) ?>"> 
     </a> 
     <?php endif ?> 
    <?php endforeach ?> 
</div> 
</div> 
<?php endif ?> 

和起作用的!谢谢