2011-02-22 28 views
1

我試圖在我的Magento網站的主頁上從Ajax調用phtml文件。我基本上創建了app/design/frontend/base/default/template/catalog/product/list.phtml的副本,並對其進行了定製以查看特定類別。如果我在CMS部分添加一個指向此文件的塊,我可以很好地查看它。不過,我想通過Ajax調用這個文件。Magento:通過Ajax調用模板phtml文件

我按照說明創建了一個模塊here,然後我試圖按照this post遵循Magento中的Ajax邏輯。然而,在最後一步它列出:

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

我在哪裏插入呢?另外,對於template="module/template.phtml",指的是哪個文件夾?

回答

2

這一點xml需要放在layout/xml文件中,這些文件位於app/design/frontend/base/default/layout /目錄中。您可以使用該snippit更新任何佈局文件,但我不建議這樣做。我通常建議在模板的佈局目錄(app/design/frontend/*/*/layout/local.xml)中創建一個local.xml文件。

現在,請確保您更新了xml snippit,以便它說明您的真實模塊,控制器和操作名稱! :)

template =「module/template.phtml」也需要定製以反映phtml文件的路徑。因此,如果您將自定義phtml文件放在app/design/frontend/*/*/template/myfolder/myphtml.phtml中,則代碼將爲template =「myfolder/myphtml.phtml」

相關問題