0

我已经在我的自定义它们中将引导模式集成到 Magento 电子商务中,它工作得非常好,除了一个问题:使用 .phtml 模板文件时加载模式内容的延迟 2 秒。

如果我使用存储在根文件夹之外的目录中的 .html 文件,它会毫无延迟地无缝加载,并且看起来很漂亮。同样,如果我将模态内容嵌入到同一页面中,它也会正确加载。

不幸的是,这些都不是一个真正的选择:使用 .html 会阻止我在需要时在模态部分中使用 php 脚本,并且我不想通过嵌入模态内容来弄乱页面;我想让他们分开在他们自己的部分。

我编写的模块相当简单,控制器只包含以下内容:

public function rebatesAction(){
        $block = $this->getLayout()->createBlock('core/template')->setTemplate('partials/modals/rebates.phtml');
        $this->getResponse()->setBody($block->toHtml());
    }

我的问题是,如何在使用这种方法加载模态内容时消除 2 秒的延迟?或者,是否有其他我未在此处列出的方法可以解决此问题?

4

1 回答 1

0

我找到了以下解决此问题的方法:

<?php echo $this->getLayout()->createBlock('moduleName/blockType')->setTemplate('moduleName/templateName.phtml')->toHtml(); ?>

It's probably the least elegant way of doing this in Magento but it works. I'm sure the better way would be to use local.xml inside of the layout directory within your theme, but I can't figure it out at the moment on my own.

于 2013-08-01T16:23:59.603 回答