2

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.

2

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.

| improve this answer | |
1

Try

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

If it doesnot work check if you have declared it in page.xml:

<block type="core/text_list" name="languagesreference" as="languagesreference"/>
| improve this answer | |
  • Doesn't work. I think it is a logical problem. – Klevis Miho Aug 1 '14 at 11:43
  • Have you cleared cache after making this change? – TBI Infotech Aug 1 '14 at 11:45
  • I have update check your page .xml – TBI Infotech Aug 1 '14 at 11:47
  • Nope, doesn't work. I have updated my question with a possible solution, but don't think it's the right way. – Klevis Miho Aug 1 '14 at 11:52
1

Locate page.xml file located in app/design/frontend/base/default/layout directory.

Find the following code.

<block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>

The above code is placed in page/html_footer block, we have to change it's location and insert it in page/html_header block as shown below.

<block type="page/switch" name="store_switcher" as="store_switcher" template="page/switch/stores.phtml"/>

You can now access the store switcher from the header. Now find the header.phtml file located in the app/design/frontend/base/default/template/page/htmldirectory.

Add the following PHP code to call the store switcher.

<?php echo $this->getChildHtml('store_switcher') ?>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.