Forums / General Questions / PHP scripts in ezpages or define pages possible?

PHP scripts in ezpages or define pages possible?

Views: 3,046

Results 1 to 15 of 15
9 Mar 2008, 3:57 AM
#1
bangsters avatar

bangsters

Zen Follower

Join Date:
Jun 2006
Posts:
168
Plugin Contributions:
0

PHP scripts in ezpages or define pages possible?

Hi.

I need to create some ezpages, but I need to insert php functions and scripts. Is this possible in the ezpages section? I can create an external page but then I would need to recreate the template just so it looks like the rest of the site, hence I would rather use the ezpages.

Please let me know how this can be done.

Thanks

9 Mar 2008, 4:34 AM
#2
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: PHP scripts in ezpages or define pages possible?

define page = yes
ezpage = not sure, probably not. Give it a try tho.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

9 Mar 2008, 4:38 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: PHP scripts in ezpages or define pages possible?

actually, no for both cases, unless you write custom code to parse your PHP code specifically

You might check out swguy's posts on the topic for suggestions on how he does that with replaceable keywords

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

9 Mar 2008, 4:40 AM
#4
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: PHP scripts in ezpages or define pages possible?

DrByte, I believe I had php code worked pretty fine for define page (version 1.3.8 checked)
Since it's only a .php file that is included anyway. Just use <?php ?> and put the code in between.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

9 Mar 2008, 4:43 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: PHP scripts in ezpages or define pages possible?

Ah, yes, that works, but not if you use a browser-based wysiwyg editor to handle your content. Edit the define_xxxxxx.php files directly and that can work.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

9 Mar 2008, 4:44 AM
#6
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: PHP scripts in ezpages or define pages possible?

Or just use the plain-text editor.

I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

13 Mar 2008, 4:24 PM
#8
netwiser avatar

netwiser

New Zenner

Join Date:
Aug 2006
Posts:
49
Plugin Contributions:
0

Re: PHP scripts in ezpages or define pages possible?

Not as elegant, but I have accomplished this by calling the *.php (file) in an Iframe.

Quick & works in my experience.

Bob

30 May 2008, 5:28 PM
#9
dgsignal avatar

dgsignal

New Zenner

Join Date:
May 2008
Posts:
31
Plugin Contributions:
0

Re: PHP scripts in ezpages or define pages possible?

Hey guys,

I too am trying to add php into an ezpages file:

http://www.zen-cart.com/forum/showthread.php?t=99102

Any suggestions? Could this be an issue with permissions?

Thanks,

D

Moderator note: moved discussion to existing thread on same topic*

1 Jan 2011, 1:33 AM
#11
finlander avatar

finlander

Zen Follower

Join Date:
Oct 2010
Location:
Idaho
Posts:
293
Plugin Contributions:
0

Re: PHP scripts in ezpages or define pages possible?

I looked in the forum but could not find info about putting php in a Define Page (such as define_main_page) rather than putting php in an ezpage. Is there method for this?

1 Jan 2011, 1:40 AM
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: PHP scripts in ezpages or define pages possible?

No "method"... just edit the define_xxx.php in Notepad++ or another good file editor. You can, as has been pointed out, also add PHP code in admin > Tools > Define Pages Editor as long as you use plain text mode.

1 Jan 2011, 4:13 AM
#13
finlander avatar

finlander

Zen Follower

Join Date:
Oct 2010
Location:
Idaho
Posts:
293
Plugin Contributions:
0

Re: PHP scripts in ezpages or define pages possible?

Glenn, we solved this in the other thread (http://www.zen-cart.com/forum/showthread.php?p=977519#post977519) but maybe it's good to point out that not all php will work on any page? In other words, there might have been some page-specific dependencies that were not allowing my php to work in define_main_page.php.

I was trying to use php (from tpl_index_categories) in the tpl_index_default file. Putting the php code in the define_main_page file wouldn't work, and it still wouldn't work when I put the php code directly into tpl_index_default, so I'm thinking there was something in the code that depended on the the php being executed directly from tpl_index_categories. The code is below that I was trying to get to execute from tpl_index_default; I can't spot a dependency on tpl_index_categories, but there must be something that causes tpl_index_default to break when this code appears in it (such as tpl_index_default not being a top-level cat page and maybe that is necessary for this code to work).

<?php require($template->get_template_dir('tpl_modules_category_row.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_category_row.php'); ?>
5 Jan 2011, 3:15 PM
#14
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: PHP scripts in ezpages or define pages possible?

I think it's not that PHP "doesn't work" in any particular file, but that some PHP code depends on using information that may not be available or variables that may not exist in the new file the code is transplanted into.

It may be that the require in tpl_index_default is working fine, but calling tpl_modules_category_row.php when there is no top category defined results in errors in that file.

2 Mar 2018, 9:21 AM
#15
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,875
Plugin Contributions:
7

Re: PHP scripts in ezpages or define pages possible?

Just to paraphrase the answers here more succinctly.

The answer is yes, php scripts in these pages will be parsed with no problem.

But, that is no guarantee that the variables/constants you are trying to use/manipulate with said php will actually be available/exist to use on that particular page. If you find that is the case, use the Superglobals plugin to find out what IS available on the page of interest.

Secondarily, you should edit these files with a plain text editor. Using a wysiwyg editor like CKeditor in a browser will mangle the php snippets when it saves the file. In CKeditor's case it turns them into html comments. There is info on the web about how you may hack it to prevent this behaviour. I spent five minutes not getting that to work: it was not worth the effort for me.

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...