Zen Cart Logo
Forums / General Questions / Running PHP in EZ-Pages

Running PHP in EZ-Pages

Views: 885

Results 1 to 11 of 11
9 Mar 2013, 11:02 PM
#1
rfree190 avatar

rfree190

Zen Follower

Join Date:
Sep 2007
Posts:
176
Plugin Contributions:
0

Running PHP in EZ-Pages

Can you run php code within an ez-page?
I added some code but it keeps getting commented out.

<?php
``` turns into ```
<!--?php

Thanks

9 Mar 2013, 11:11 PM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Running PHP in EZ-Pages

In general, you cannot run php in an EZpage, because the CONTENT of EZPages is stored in the database, not in the file system. As the sequence of output assembly is important in PHP, it would have "run its course" before the database content is parsed into the output.

It's kinda a "cart before the horse" situation.

There IS an over-ride - and it has been discussed before on the forum, so try look for it.

Additionally, you could try either switching OFF your CK Editor while you work on source-type coding, or you could "toggle" to source mode, and SAVE without toggling back to wysiwyg.

But you will probably still need the over-ride technique first...

9 Mar 2013, 11:15 PM
#3
rfree190 avatar

rfree190

Zen Follower

Join Date:
Sep 2007
Posts:
176
Plugin Contributions:
0

Re: Running PHP in EZ-Pages

Thank you for the quick reply.
I have had luck using php code in a "Define Page", ie; page_2.php. What is the process for adding additional Define Pages? page_5.php, etc...

9 Mar 2013, 11:19 PM
#4
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Running PHP in EZ-Pages

Define pages are FILE BASED (not stored in the database like EZpages are).

9 Mar 2013, 11:25 PM
#5
rfree190 avatar

rfree190

Zen Follower

Join Date:
Sep 2007
Posts:
176
Plugin Contributions:
0

Re: Running PHP in EZ-Pages

I can find page_2.php defined in three locations:

/includes/templates/default_template/templages
/includes/languages/english/html_includes/
/includeslanguages/english/MY_TEMPLATE/

I have copied and renamed to page_5.php, but it is not picking it up. I think I must be missing a page somewhere.

9 Mar 2013, 11:27 PM
#6
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Running PHP in EZ-Pages

There is a technique to creating and/or re-naming the define pages. I do not use these extra pages any more, so I've forgotten the procedure, but there are lots of posts about how you do this, and I think there is also a Tutorial/FAQ topic on it.

9 Mar 2013, 11:31 PM
#7
rfree190 avatar

rfree190

Zen Follower

Join Date:
Sep 2007
Posts:
176
Plugin Contributions:
0

Re: Running PHP in EZ-Pages

Thank you for your assistance. I'm off to the FAQ section!

9 Mar 2013, 11:31 PM
#8
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Running PHP in EZ-Pages

Remember also to follow the principles of the OVER-RIDE system

You will always need a DEFAULT define page in the ROOT html_includes folder

\includes\languages\english*html_includes*

(In here you will see all the CORE define_page_xxxx.php files)

Then, you need an OVER-RIDE for each and every one, in the OVER-RIDE folder:

\includes\languages\english*html_includes*YOUR_TEMPLATE_FOLDER

9 Mar 2013, 11:37 PM
#9
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Running PHP in EZ-Pages

If you do not have a YOUR_TEMPLATE_NAME folder at that location, create one...

make sure ALL the define_page_xxxx.php files are COPIED into that over-ride folder, as (if there is no over-ride folder) it is likely you have been editing the CORE files.

In general, the RULE for over-ride folders is quite simple (especially in the languages directories...)

Wherever you see a "classic" folder, you will need a CUSTOM folder named after the custom template you are using. These "over-ride" folders are only needed when you make customisations (edits) to a CORE or DEFAULT file.

It is NOT necessary to have an over-ride folder if there are no CUSTOM edits to a core file, but one of the first things I do when installing a new template, is go create all the corresponding over-ride folders - and I just leave them empty.

There is a download in the plugins area that illustrates the over-ride directory tree. But as I said... Wherever you see a "classic" folder, it indicates the "availability" of an over-ride folder named after your custom template.

10 Mar 2013, 12:26 AM
#10
rfree190 avatar

rfree190

Zen Follower

Join Date:
Sep 2007
Posts:
176
Plugin Contributions:
0

Re: Running PHP in EZ-Pages

Thank you for all the info.
I followed it and now have page_5 - page_10 up and running!!!
I probably won't need all 10, but they are there and ready if I ever do.

10 Mar 2013, 12:40 AM
#11
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Running PHP in EZ-Pages

Excellent...

Another useful "trick" is to leverage the capacity for EZ-pages to act as internal hyperlinks.

What I do on most sites, is de-activate the "Information" sidebox completely - and all the "define pages" and other internal links in that box, I assign to EZ-Pages, using the "internal link" function.

So... for example: I create an EZ-Page called "Contact Us", then in the "Internal Link" field, I type: index.php?main_page=contact_us .

I now have a feature where I can place the "EZ-Page" (now just a link) in either the HEADER BAR, SIDEBOX or FOOTER (or any combination of these three).

This allows for putting things like "Privacy Notice" and "Conditions of Use" in the footer, using "Above-The-Fold" space for more important content such as BUY THIS PRODUCT!