Magento的:通过Ajax调用模板PHTML文件 [英] Magento: Call template phtml file via Ajax

查看:175
本文介绍了Magento的:通过Ajax调用模板PHTML文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图打电话对我的Magento站点的主页从阿贾克斯一个PHTML文件。基本上,我创建了应用程序/设计/前端/基/默认/模板/目录/产品/ list.phtml的副本,并对其进行了定制,以查看特定类别。如果我添加一块指向CMS中的部分文件,我可以查看它就好了。不过,我想打电话给通过Ajax这个文件。

I'm attempting to call a phtml file from Ajax on the homepage of my Magento site. I basically created a copy of app/design/frontend/base/default/template/catalog/product/list.phtml and customized it to view a particular category. If I add a block pointing to this file in the CMS section, I can view it just fine. However, I want to call this file via Ajax.

我按照说明创建一个模块<一个href="http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-3-magento-controller-dispatch/"相对=nofollow>此处,然后我试图通过下面跟随阿贾克斯在Magento的逻辑的这个帖子。然而,在最后一步它列出:

I followed the instructions to create a module here, and then I attempted to follow the logic of Ajax in Magento by following this post. However, in the last step it lists:

&LT; module_controller_action&GT;
  &LT;块类型=模块/块NAME =根输出=toHtml模板=模块/ template.phtml/&GT;
&LT; / module_controller_action&GT;

<module_controller_action>
<block type="module/block" name="root" output="toHtml" template="module/template.phtml"/>
</module_controller_action>

我在哪里插入呢?此外,对于模板=模块/ template.phtml,什么文件夹是指?

Where do I insert this? Also, for the template="module/template.phtml", what folder is that referring to?

推荐答案

需要XML的该位被放在一个布局的XML文件,该文件被发现在app /设计/前端/基/默认/布局/目录。您可以更新任何与该的这段布局文件,但是我不建议。我通常建议在创建模板的布局目录(应用程序/设计/前端/ * / * /布局/那个local.xml)一个local.xml文件,。

That bit of xml needs to be put in a layout xml file, which are found in the app/design/frontend/base/default/layout/ directory. You can update any of the layout files with that snippit, but I don't recommend that. I usually recommend creating a local.xml file in your template's layout directory (app/design/frontend/*/*/layout/local.xml).

现在,请确保您更新XML的这段也因此,它说你的真实模块,控制器和动作名称! :)

Now, make sure you update the xml snippit too so that it says your real module, controller, and action name! :)

模板=模块/ template.phtml也需要进行定制,以反映路径PHTML文件。所以,如果你把你的自定义PHTML文件在app /设计/前端/ * / * /模板/ MyFolder中/ myphtml.phtml,那么code将模板=MyFolder中/ myphtml.phtml

The template="module/template.phtml" will also need to be customized to reflect the path to the phtml file. So if you put your custom phtml file in app/design/frontend/*/*/template/myfolder/myphtml.phtml, then the code would be template="myfolder/myphtml.phtml"

这篇关于Magento的:通过Ajax调用模板PHTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆