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

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

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.


1
{{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:

:app/design/fronend/default/default/template/myphp

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

:app/design/fronend/default/default/template/myphp

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.
Reply   

Bookmarks


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


Our volunteer moderators and their websites:
David Wallace
SearchRank - Organic Search Engine Optimization
Old Welsh Guy
Internet Marketing from Wales in the UK
torka
NineYards.com: Helping Businesses Do Business Online
Small Business Answers
Free help to grow your business.

New at Search Engine Guide
The 4 Types Of Website Traffic

New at Small Business Answers
Contractor Estimate - Cancel Contract - Bill of Sale - Evaluation Questions

Employee Evaluation Templates
30 Day Review - 90 Day Review - Annual Review - Employee Self Evaluation - Strength & Weaknesses

New at Small Business Forum
Unusual Ways To Promote Your Business

Crimson Fox
Graphic Design and Brand Promotion and the Brand Design Blog
St0n3y
Search Marketing Results - Pole Position Marketing!
Search Marketing Info - (EMP) E-Marketing Performance
Matt McGee
Small Business SEM - Web marketing discussion for small businesses.
Logan
Tiny Doors Frisco
Things To Do

At Your Business - Small Business Directory
Free Business Forms - Prewritten Documents

Free Links - Free Advertising
Free Guide - Online Directory
Debra Mastaler
Alliance-Link
The Link Spiel Blog
ChristineG
Free Online Marketing and Social Media Tips: Social Media Simplified for Small Business Owners
mktgbiz
Promotional Items Marketing
What I REALLY think!


Visit our small business websites
Small Business Forum | Small Business Answers | Search Engine Guide

All times are GMT -5. The time now is 06:57 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright 2004 - 2015 K. Clough, Inc. - Privacy