Sarathlal N

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.

Got a project in mind? Send me a quick message, and I'll get back to you within 24 hours!.

Recent Posts

  1. Disabling Payment Methods in WooCommerce Based on Conditions
  2. How to Update Product Quantity in WooCommerce Using Custom Code
  3. Dynamically Generating a Table of Contents in WordPress
  4. Direct Checkout in WooCommerce - Add Product to Cart from Checkout Page & Skip Shop, Product, and Cart Pages
  5. Understanding the Impact of git reset --hard Command

Your Questions / Comments

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