Calling the phtml file from cms page – Magento 1x

This tutorial is about calling the phtml template on the cms page. This tutorial will be straightforward. In summary, We will create a new page in the admin panel and a custom phtml file in the backend. So, before we move forward this tutorial is applied only on the Magento 1x.

Step 1:

Login into the admin panel and hover over the cms nav and click on the pages

Step 2:

After that you will see the cms manage page, click on the add new page button and enter

Page Title: Enter the page name. For example Homepage 1

URL Key: Enter the url key. For example homepage_one. The identifier is one which will be used to call in the phtml file.

Store View: Select the appropriate store to display that page.

Status: Select enabled

Content: Enter the content
In the content part, we enter this code to call the phtml file.

 {{block type="core/template" template="page/custom-template.phtml"}} 

If you write to visit the page, i.e. [http://domainname.com/homepage_one] the page will display empty because we have not created any file on the backend.

Step 3:

Go to the template folder (app > design > frontend > themename > default > template > page). You can use another folder if you want to for this tutorial I am using the Magento default page folder.

Create a file named custom-template.phtml and write “hello world” for test purposes to check if the page is called successfully.
After you have saved the file, please don’t forget to clear the cache.

Additional Point:

As well as we can pass the category id or product id and use it in the phtml file. Have a look at the code where the category id has been passed and called in the phtml file


{{block type="core/template" template="page/custom-template.phtml" category_id="23"}} 


getData('category_id'); 
?>