Templates 如何获得网站切换器而不是商店切换器?
我如何创建一个下拉菜单来切换网站而不仅仅是商店Templates 如何获得网站切换器而不是商店切换器?,templates,layout,web,magento,switching,Templates,Layout,Web,Magento,Switching,我如何创建一个下拉菜单来切换网站而不仅仅是商店 更具体地说,我想在Magento网站之间切换。模板中有一个下拉菜单用于切换商店,一个用于切换语言,但没有一个用于切换网站。在Magento论坛上找到了一个解决方案: 您必须在自定义主题包中创建app/design/frontend/base/default/template/page/switch/stores.phtml模板的副本 然后您必须修改它以使用以下代码: <?php $websites = Mage::app()->getW
更具体地说,我想在Magento网站之间切换。模板中有一个下拉菜单用于切换商店,一个用于切换语言,但没有一个用于切换网站。在Magento论坛上找到了一个解决方案: 您必须在自定义主题包中创建
app/design/frontend/base/default/template/page/switch/stores.phtml
模板的副本
然后您必须修改它以使用以下代码:
<?php
$websites = Mage::app()->getWebsites();
if (count($websites) > 1): ?>
<div class="website-switcher">
<label for="select-website"><?php echo $this->__('Select Store:') ?></label>
<select id="select-website" title="<?php echo $this->__('Select Store') ?>" onchange="location.href=this.value">
<?php foreach ($websites as $website): // print out each website name and code as a dropdown box item ?>
<?php $_selected = $website->getCode() == Mage::app()->getWebsite()->getCode() ? ' selected="selected"' : '' ?>
<option value="<?php echo $website->getDefaultStore()->getBaseUrl()?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($website->getName()) ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>