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?

  • 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 Nov 26 '15 at 10:43
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);
}
  • its not showing me store view.. – Dibyasri Nov 27 '15 at 4:55
  • Hi Dibyasri, did you ever get this to work? I'm curious to the solution you have found. – 7ochem Jan 6 '16 at 11:02

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.