Zen Cart Logo
Forums / General Questions / Making an EZ-page with PHP code?

Making an EZ-page with PHP code?

Locked

Views: 1,243

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
10 Oct 2007, 5:58 PM
#1
emilfalcon avatar

emilfalcon

New Zenner

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

Making an EZ-page with PHP code?

Hi,

I need to add the equivalent to an EZ-page but it must contain some PHP code as I am doing some specific server-side operations on that page.

How can I do this?

I tried creating a directory called "php_script" in my includes/templates/CUSTOM/ directory and copied tpl_main_page.php in there and then tried calling index.php?main_page=php_script in my browser but just got a 404 error. How can I point the controller to my script?

Thanks!

10 Oct 2007, 7:00 PM
#3
emilfalcon avatar

emilfalcon

New Zenner

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

Re: Making an EZ-page with PHP code?

Thanks, that's helpful.

However, this seems to be a particularly slow solution. If the PHP is stored in a database then the whole thing must be running through an eval() statement?

Is there a way to achieve the same functionality by simply creating a PHP script and having it be included whenever a certain url is accessed, the same way the templating system works for shopping cart pages for example? (ie copying & modifying tpl_main_page.php into includes/templates/CUSTOM/shopping_cart dir modifies the page index.php?main_page=shopping_cart)

10 Oct 2007, 7:54 PM
#4
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,604
Plugin Contributions:
0

Re: Making an EZ-page with PHP code?

Perhaps a bit more detail in exactly what you are trying to accomplish would help get better advice?

11 Oct 2007, 8:52 PM
#5
emilfalcon avatar

emilfalcon

New Zenner

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

Re: Making an EZ-page with PHP code?

I basically want to output form variables on a custom page.

So on my home page I have:

<form method="post" action="formscript.php">
<input type="text" name="test" />
<input type="submit" value="Submit" />
</form>

And on formscript.php I would have:

<?php echo $_POST['test'] ?>

I need formscript.php to output this in the main box of the ZenCart template.

It's just adding a basic custom application to a zencart installation...not sure how else to explain it.

11 Oct 2007, 8:56 PM
#6
emilfalcon avatar

emilfalcon

New Zenner

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

Re: Making an EZ-page with PHP code?

another way of asking the same thing is:
how can I add a new page to Zen Cart without using the EZ-page editor and instead actually creating a new file?

11 Oct 2007, 10:07 PM
#7
emilfalcon avatar

emilfalcon

New Zenner

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

Re: Making an EZ-page with PHP code?

figured out a complicated way of doing this...in case anyone out there had a similar problem:

1- create an EZ page with the name you want and note its ID
2- edit templates\template_page_default.php, changing:

echo $var_pageDetails->fields['pages_html_text'];

to

if ($var_pageDetails->fields['pages_id']=="YOUR_ID"){ 
	require($template->get_template_dir('SCRIPT_NAME.php',DIR_WS_TEMPLATE, $current_page_base,'SCRIPT_DIR'). '/SCRIPT_NAME.php');
} else { 
	echo $var_pageDetails->fields['pages_html_text']; 
} ?>

place your script in the templates/CUSTOM/SCRIPT_DIR directory

12 Oct 2007, 3:29 AM
#8
drbyte avatar

drbyte

Sensei

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

Re: Making an EZ-page with PHP code?

emilfalcon:

another way of asking the same thing is:
how can I add a new page to Zen Cart without using the EZ-page editor and instead actually creating a new file?

Just add a new page!

You could use the About Us contribution in the downloads area as an example. It contains a readme which explains the process. There are some other additional-page contributions which could be adapted similarly.