如何从URL调用php模板文件


Magento - How to call a phtml template file from the URL

这个问题几乎说明了一切。我有一个商店定位程序。它动态地生成如下URL:

http://www.XXXX.com/storelocator/index/viewstore/id/XXX

模板文件也在右边的目录下:

package/template/storelocator/view_store.phtml

app/code/local/COMPANY/Storelocator

当我单击由Javascript生成的ID时,它返回404错误。显然模板文件没有加载。但我不确定是什么导致了这个问题。谁能给我一些建议?

如果没有尝试在布局文件中分配您的块,请在布局文件中分配您的模板文件。

<storelocator_index_viewstore>
 <block type="Storelocator/Storelocator" template="storelocator/view_store.phtml"></block>
</storelocator_index_viewstore>

这样当你的动作是调用magento渲染这个块然后调用你的php文件