Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates 如何获得网站切换器而不是商店切换器?_Templates_Layout_Web_Magento_Switching - Fatal编程技术网

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