How can I execute PHP code in a page?
I'd like to setup a custom order form for a special product. This probably won't even go through the zencart checkout system, its just a way to fill out a form and submit it.
I could just stick up a php page on my side, but I'd really like it to look like the rest of the site, with header, footer, menus, etc. So I started doing it in one of my custom pages using the page editor, but when I view the site, all my php code ( stuff between <?php and ?>) was stripped out.
How can I have a page on the site that will be executed? I've dug around these forums and various FAQs but couldn't find an answer.
Thanks!
Re: How can I execute PHP code in a page?
Now that I think about it, it may be possible to just do this as a product in the cart. If I can add several custom fields that customers can fill in, and I will use a popup window to show the 15 different color images... what would be nice is if I could make a custom product page, where I could control where the 'color' drop down box shows up, so I can put a link to a popup color picker next to it, etc.
Any advice appreciated. I'm still curious on how to get zencart to execute php in a page, too.
Re: How can I execute PHP code in a page?
the editor will process html I know...noit sure about php entered this way. Youcould create a php file to be called and include the applicationtop in it for the same look.
A form though is normally html kinda like:
Code:
<html>
<head>
<title>Personal INFO</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
First Name:<input type="text" size="12" maxlength="12" name="Fname">:<br />
Last Name:<input type="text" size="12" maxlength="36" name="Lname">:<br />
and then you can enter this in the editor or call it from php.
I think that Zen Cart uses js forms though
Re: How can I execute PHP code in a page?
You cannot enter PHP via FCKEditor, HTMLArea, etc. as these are designed strictly to build HTML pages WYSIWYG-style. They treat everything as if it should appear on the screen exactly as you have typed it, and will strip or otherwise scrub code.
It's really not that hard to create new pages within the Zen Cart system. Take a look at the templating system. includes/templates/template_default/templates/tpl_page_2_default.php is left over form the pre-"EZ Pages" days, but it's a perfect, simple example of the what and how in building your own pages.
Speaking of EZ Pages, that could also be a possible solution. You should take a look at the documentation for it to see if you can use that.
Re: How can I execute PHP code in a page?
I'm not using the wysiwyg editor, I'm just using the plain text area. I'm not ending up with the actual tags and code, what happens is that the php code is just gone, it seems like zencart is stripping it out.
If I do AA<?php phpinfo(); ?>BB
I just end up with AABB on the page.
And I think I might be using the EZ pages, I'm doing it through the Page Editor, which I think reads and writes files in something like the english/templates directory.
I think what I'm going to do is have a link to a popup window that has the color options, all 15 images using a roll-over, etc. in it. THen when those choices are done, use javascript to write them back to a text field in the product page.
Re: How can I execute PHP code in a page?
Diff scenario, same result: code is scrubbed out from the define pages, as they are only expected to contain HTML.
Quote:
I think what I'm going to do is have a link to a popup window that has the color options, all 15 images using a roll-over, etc. in it. THen when those choices are done, use javascript to write them back to a text field in the product page.
I think you're making this more complicated than it needs to be. Bite the bullet and teach yourself about the templating system. It'll pay dividends when it comes time to do more complex customizations or troubleshoot an upgrade/modification. Definitely speaking from experience on this one.
Re: How can I execute PHP code in a page?