1

I have created multi-currency selector in header using following logic

Updated app/design/frontend/default/my_theme/layout/local.xml as per follow <?xml version="1.0"?> <layout version="0.1.0"> <default> <reference name="header"> <block type="directory/currency" name="my_currency_selector" template="currency/currency.phtml"/> </reference> </default> </layout> In app/design/frontend/default/my_theme/page/html/header.phtml added:

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

Its works perfectly fine.

Now problem is that, I have ajax call on list page because of this I need to reload my_currency_selector in controller. I used following code which return me breadcrumbs block html. $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')->toHtml(); But same code is not working for currency. I tried $currency = $this->getLayout()->getBlock('my_currency_selector')->toHtml();

Please tell me What I am mising

1

The ajax action you perform has it's own layout handle, and usually AJAX calls don't load the default layout handle.
This means that your block does not exist in the ajax call.
You need to add this block in the layout handle for your ajax call and it should work nicely.

  • As breadcrumbs loads without adding it to layout handle for ajax call. I think problem is that my_currency_selector is inside header. First I have to load header and then my_currency_selector. – Sandesh May 18 '15 at 14:53
  • You are indeed right! same as all time – Sandesh May 19 '15 at 4:31

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.