1

How do I implement store switcher through controllers instead of using block template to implement store view like this:

<forum_admin_adminhtml_forum_edit>
    <reference name="left">
         <block type="adminhtml/store_switcher" name="store_switcher" template="store/switcher.phtml" />
    </reference>
</forum_admin_adminhtml_forum_edit>

How can I implement store switch through controllers?

1
  • Please add more details to the question about what exactly you want to achieve with the controllers. That layout file merely generates some HTML content.
    – Prateek
    Commented Nov 26, 2015 at 10:43

1 Answer 1

0

In a controller you can achieve the same as the layout XML that you have provided with the following code after you have called $this->loadLayout(); but before $this->renderLayout();:

$leftBlock = $this->getLayout()->getBlock('left')
if (false != $leftBlock) {
    $storeSwitcherBlock = $this->getLayout()
        ->createBlock('adminhtml/store_switcher', 'store_switcher')
        ->setTemplate('store/switcher.phtml');
    $leftBlock->append($storeSwitcherBlock);
}
2
  • its not showing me store view..
    – Dibyasri
    Commented Nov 27, 2015 at 4:55
  • Hi Dibyasri, did you ever get this to work? I'm curious to the solution you have found.
    – 7ochem
    Commented Jan 6, 2016 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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