Magento – Change position of store switcher

layoutswitcher

I want to add the store switcher to page/template/links.phtml

And I have this on local.xml

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <default>
        <reference name="root">
            <block type="core/text_list" name="languagesreference" as="languagesreference" translate="label">
                <label>Languages reference</label>
            </block>
        </reference>
        <reference name="languagesreference">
            <block type="core/template" name="languagesreferenceblock" template="page/switch/languages.phtml" />
        </reference>
    </default>
</layout>

And on page/template/links.phtml:

<?php echo $this->getChildHtml('languagesreference') ?>

What am I doing wrong here?

UPDATE: I managed to fix it by adding this to local.xml:

<reference name="top.links">
    <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
</reference>

But I have a lot of uncertainty here.

Best Answer

What you can do is firstly remove the current placing of the block with a call to unsetChild and then use a call to insert to set the new place.

<default>
    <reference name="header">
        <action method="unsetChild"><name>store_language</name></action>
    </reference>
    <reference name="top.links">
        <action method="insert"><block>store_language</block></action>
    </reference>
</default>

This should then allow you to move the position of the language chooser from the standard block to the new block.

Related Topic