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

时间:2015-03-02 11:53:18

标签: 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 ?>

现在我们要隐藏当前语言的标志。因为你不需要看到它。我们怎样才能创造这个?

2 个答案:

答案 0 :(得分: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 ?>

答案 1 :(得分:0)

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

这很有效!感谢