在 Magento 的语言选择器中隐藏当前标志

Hide current flag from language selector in 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 ?>

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

试试这个希望它能完成你的工作

<?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 ?>

我将 Rohit Goel 的代码更改为:

 <?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 ?>

成功了!谢谢