Magento在模板文件中获取语言名称和语言代码

时间:2015-10-21 14:21:25

标签: php magento-1.9

Magento获取语言名称和语言代码 (see screenshot) 在模板文件中生成此代码:

<div class="gb">EN</div>

所有代码:

<?php if(count($this->getStores())>1): ?>

<div class="gb">EN</div>

<ul class='dropdown-menu'>
 <?php foreach ($this->getStores() as $_lang): ?>

    <li>
        <div class="<?php echo $this->htmlEscape($_lang->getCode()) ?>"><?php echo $this->htmlEscape($_lang->getName()) ?></div>
    </li>
<?php endforeach; ?>
</ul>

谢谢

1 个答案:

答案 0 :(得分:-1)

代码:

<div class="<?php echo $this->htmlEscape(Mage::app()->getStore()->getCode()) ?>"><?php echo $this->htmlEscape(Mage::app()
->getStore()->getName()) ?></div>

所有代码:

<?php if(count($this->getStores())>1): ?>

<div class="<?php echo $this->htmlEscape(Mage::app()->getStore()->getCode()) ?>"><?php echo $this->htmlEscape(Mage::app()
->getStore()->getName()) ?></div>

<ul class='dropdown-menu'>
<?php foreach ($this->getStores() as $_lang): ?>

<li>
    <div class="<?php echo $this->htmlEscape($_lang->getCode()) ?>"><?php echo $this->htmlEscape($_lang->getName()) ?></div>
</li>