Welcome to the Small Business Ideas Forum! We are a community of over 100,000 small business folks with over 163,000 posts for you to browse. We pride ourselves on being the friendliest forum you will find and we'd love to have you as a member of our community. Please take a moment and register for a free account. If you need any help, please contact Chris Logan.

Small Business Ideas Forum

Small Business Ideas Forum

A friendly place to share small business ideas and knowledge, ask questions, find help and encourage others that are involved in the small business industry. Topics include small business marketing, generating revenue and small business computing.

Go Back   Small Business Ideas Forum > Generating Revenue, Insurance, Taxes, Etc. > Ecommerce
Register Search Today's Posts Mark Forums Read

Thread Tools
Old 7th November 2014, 09:11 AM   #1

Join Date: Sep 2013
Location: Ukraine
Posts: 23
Default Your PHP Code In Magento CMS Page

We have few options to add PHP code in Magento CMS page directly. You can use a regular expression, you can create a module and put custom code into a block which is calling from CMS page with the help of script or create custom php codes in admin section then use them in any Magento CMS page you want.

I will write about the two last options.

1. Call template files via blocks in Magento CMS page

First you need to add a new .phtml file with the custom PHP code inside (let’s call it newfile.phtml).

Than we have to call this file in HTML file as block with the help of code snippet written below.

{{block type="core/template" template="page/newfile.phtml"}}
page/newfile.phtml – the path to the template file with the content

core/template – a module that will process the template

We can put this file into already existing or a new folder. Be careful when call as block, point out the correct way to the file.

This way is pretty good and easy, but not optimal.

2. Module with custom PHP code

If we create a module where we can add a custom piece of PHP code in admin section, we will be able to use it in any Magento CMS page.

Let’s call our module “myphp”. This module will contain two parts:

1) The frontend part. Create there new file and name it myphp:


2) The admin part contains a feature to list and edit file content in the folder:


You should create there .phtml file. (for example let’s call it myphpcode.phtml). This file should contain the following code:

<? php echo

(“Here I can write my custom PHP code”);


You just need to insert snippet

<block type=”core/template” name=”myphpcode” template=”myphp/myphpcode.phtml”/>

in your PHP code.

Now you have a new module which you can use in Magento CMS pages.

webinse is offline   Reply With Quote
Register or log in to remove this ad.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Facebook Fan Page Nutty Social Media 14 2nd March 2015 05:24 AM
Php Code For Valid RSS Time Format fairdoes Website Development 3 31st December 2014 10:22 AM
How To Increase Page Rank Of Website! seowebtech Search Engine Optimization 40 26th February 2010 12:47 AM
Parse .html Pages For Php Code Robert Website Development 7 15th August 2007 05:46 PM

Thread Tools

Get Updates
RSS Feeds:
RSS Feed for Ecommerce RSS for this Category Only: Ecommerce

RSS Feed for Small Business Ideas Forum RSS for Entire Forum
Forum Rules

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Small Business Ideas Forum

At Your Business - Small Business Directory
Free Business Forms - Prewritten Documents
Search Engine Guide
Small business guide to search marketing

Small Business Brief
Fetching the Best Small Business Info

Free Links - Free Advertising
Free Guide - Online Directory

Advertise your business here
Contact us for more details!

Semantic Juice
Register now to access free Quick SEO service!

Rocket Lawyer
Sign up for free 7 day trial. Boost your biz!

Buy UPC Codes
Get your products listed online!

All times are GMT -5. The time now is 07:09 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004 - 2018 - Privacy