I have a PHTML file that loads products based on the data I send via the set data method.

e.g ->setData('xxx', $xxx)

I call this file in another PHTML file numerous times to show all products.

This means it is taking a while for the page to load.

Is there a way I can load the PHTML file or a CMS Block after page load or on click?

I am using this to show the file:

echo $this->getLayout()->createBlock('core/template')->setData('xxx', $xxx)->setTemplate('xxx/xxx.phtml')->toHtml();

Or is there a way to load PHTML or CMS Block in an iframe?

1 Answer 1


You can do it by Ajax e.g. add this in your template file :

jQuery(window).load(function() {
    jQuery.get( "http://example.com/mymodule/index/some", function( data ) {
          console.log(data); // replace this output in your page

Create a function in any controller then add this code e.g.

class Paras_Mymodule_IndexController extends Mage_Core_Controller_Front_Action

     public function someAction() {
        $html = Mage::app()->getLayout()->createBlock('core/template')->setData('xxx', $xxx)->setTemplate('xxx/xxx.phtml')->toHtml();               
        echo $html;

I know this is not complete solution but It will help you.

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.