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. Update query order - WordPress
  2. Display featured products - WooCommerce
  3. Remove "Category:", "Tag:", "Author:" from the_archive_title - WordPress
  4. The essential & basic WP-CLI commands for a WordPress developer
  5. Install theme unit test data using WP-CLI - WordPress


Questions / Comments

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