Magento:通过Ajax调用模板phtml文件
我正在尝试从 Magento 网站的主页上的 Ajax 调用 phtml 文件。我基本上创建了 app/design/frontend/base/default/template/catalog/product/list.phtml 的副本,并对其进行了自定义以查看特定类别。如果我在 CMS 部分添加一个指向该文件的块,我就可以很好地查看它。但是,我想通过 Ajax 调用这个文件。
我按照说明创建了一个模块 这里,然后我尝试通过以下 这篇文章。但是,在最后一步中它列出了:
我在哪里插入这个?另外,对于template="module/template.phtml"
,它指的是哪个文件夹?
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.
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:
<module_controller_action>
<block type="module/block" name="root" output="toHtml" template="module/template.phtml"/>
</module_controller_action>
Where do I insert this? Also, for the template="module/template.phtml"
, what folder is that referring to?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
需要将这部分 XML 放入布局 XML 文件中,该文件位于
目录。您可以使用该片段更新任何布局文件,但我不建议这样做。我通常建议在模板的布局目录中创建一个 local.xml 文件
现在,请确保您也更新了 xml 片段,以便它显示您的真实模块、控制器和操作名称! :)
还需要自定义
template="module/template.phtml"
以反映 phtml 文件的路径。因此,如果您将自定义 phtml 文件放入,那么代码将是
template="myfolder/myphtml.phtml"
That bit of XML needs to be put in a layout XML file, which is found in the
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
Now, make sure you update the xml snippit too so that it says your real module, controller, and action name! :)
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, then the code would be
template="myfolder/myphtml.phtml"