Add custom PHP code in Magento 1 CMS page

In Magento, we can’t directly add our custom PHP code in CMS page. But we have an option to call our template files as blocks in CMS page.

So if we want to use custom PHP code in Magento CMS page,

  1. first make a new template file (.phtml file) with our custom PHP code inside template folder.
  2. Then call it as a block in CMS page like below code snippet.

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

We can put our file in any where inside template or we can make new folder for this custom files. But when call as block, point to correct file path.

I made my new file inside page folder in template. So when call block, I point to my file inside page folder like page/myfile.phtml as template.

Need Help?

Do you need any help on Magento 1? I'm happy to help you.

Contact Me

Recent Posts

  1. Move files recursively from source to remote server - SCP Command
  2. Brief about Magento 2 cache commands
  3. Magento 2 customer account password options
  4. Enable or disable maintance mode - Magento 2
  5. Replace string in multiple files - Command line


Questions / Comments

If you found this article interesting, found errors, or just want to discuss about them, please get in touch.