简体   繁体   中英

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

The question pretty much says it all. I have a store locator application. Which dynamically produces a URL like:

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

And I have also the template file in right directory:

package/template/storelocator/view_store.phtml

Also the block in:

app/code/local/COMPANY/Storelocator

When I click on the ID that is generated by the Javascript, it returns a 404 error. So obviously the template file is not loading. But I am not sure what is causing the issue. Can someone give me some idea.

have you assign your template file in layout file if not try to assign your block in layout file.

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

This way when your action is call magento render this block and call your phtml file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM