![]() |
new/custom php page?
Hi there.
I have bought a new search program, and need to modify a search page. I'd like to insert some php code into it, but search.php has a lot of code and calls and programming logic that I can't seem to understand (I have tried deleting code line by line, but always get some kind of error). Is there some basic layout for a php page (that I can get a code snippet) that is basically a blank page and will allow me to put standard php code into? For that matter, is there a way to have a custom php page that has the template with "hello there" even on it in regular php, not calling a tpl page? Thanks a bunch!!! |
Re: new/custom php page?
Here is an example taken from
http://www.w3schools.com/PHP/DEfaULT.asP <html> <body> <?php echo "hello there"; ?> </body> </html> To get your content to be "surrounded" by your cart's design however you will need to create a template ("myphp.tpl")and include it by putting {include file="myphp.tpl"} in x-cart wherever you want your content to be displayed. Its not quite as simple as that but, not really much more difficult either. You may or may not need the "html" and/or "body" tags depending on where you place it in x-cart. Example: name the following myphp.tpl and save it to the root directory of x-cart Code:
<?php |
Re: new/custom php page?
Thanks a million J!
I'd like the page to sit alone though - not be a template that's included within the home page - just like either the cart.php, search.php, news.php, or any of the other php pages that only have one type of content in them. If I did this correctly, it shows on the main template on each page, not when I call xcart/mypage.php right? Thanks again! |
Re: new/custom php page?
A lot depends on how you want to access it. You could just make a static page and include a link in the speed bar. That will put your content in the "center" area of your cart (similar to your FAQ page).
Your php will probably need some of the "includes" that are used by x-cart. Look at just about any php script x-cart uses (they are near the top... (require "./auth.php"; require "./security.php"; whatever ones seem necessary). |
Re: new/custom php page?
It sounds like you are working on a "search" module, but you didn't specify if it was for the customer or admin. Anyway, what if you used the present link ("advanced search") and linked it to your new "my_search.tpl and my_search.php" using the existing search template and search.php and cloned them, putting in your own code.
I would be interested to see what you come up with. |
Re: new/custom php page?
Yep - I am trying to put together a new search module for my site. I've tried to dissect the search.php page. I've commented out just about everything to just a bare-bones page, but when I do that I get a "page not found" error.
I guess what I'm looking for is how to build a basic php page...what elements have to go in it, and where they have to be. I've gleaned from these forums that I need a php page with an include to a tpl file? my search.php is this: Code:
<?php I flushed my templates, but just for a test my tpl file: Code:
{* $Id: mysearch.tpl *} Where am I screwing up? |
Re: new/custom php page?
I've tried to use balinor's post here, but it doesn't explain how tpl's interact with php pages and vice-versa.
Thanks again! |
Re: new/custom php page?
Umm.. try looking at skin1/customer/search.tpl.
Note that it has some "search" parameters and then at the bottom of the code (after the button) it has Code:
<a href="search.php"><u>{$lng.lbl_advanced_search}</u></a> Code:
echo "hello there"; |
Re: new/custom php page?
I'm no wiz at php but I think the
require $xcart_dir."/skin1/mysearch.tpl"; is wrong. There should be a include skin1/search.tpl that calls mysearch.php, not the other way around (I think). A .tpl is pretty much html, and html can include php, but I'm not sure about the other way around. I know php can include html code, that can be displayed, but I'm not sure that entire .tpls can be used. |
Re: new/custom php page?
Quote:
If you want this page displayed on customers side in skin1/cusotmer/home_main.tpl you have to specify which template to load when your new.php is called {if $main eq "_mysearch_"} {include file="path_to_file/mysearch.tpl"} {/if} Just look at the if statement there you will get the idea |
Re: new/custom php page?
Thanks guys - I did get it to work now and am just trying to get the specific php calls working now. I'll let ya know when it's working and what I did to make it work correctly.
Thanks again! |
Re: new/custom php page?
OK guys - I have successfully implemented php being used in the tpl file. I can get it to echo "hello world". However, in the tpl file I have a call to http://www.mysite.com/my_search_file.php:
Code:
{include_php file="http://www.mysite.com/my_search_file.php"} Anyone know what gives? TIA! |
Re: new/custom php page?
Well, "not readable" is usually a permissions problem, but I'm not sure of the "include_php file" syntax.
Usually it would be a link like <a href="http://www.mysite.com/my_search_file.php">my search file</a>. Also, look at search.tpl and search.php and the way they interact with each other. In search.tpl it "calls" search.php twice, once at the beginning of the file... <form method="post" action="search.php" name="productsearchform"> and then again towards the end of the file... <a href="search.php" class="Search">{$lng.lbl_advanced_search}</a>. Each instance does something different. The first one asks for user input and then processes it. The second one "opens" search.php so the user can choose which input is relevant. Searching x-cart is a pretty involved process. |
Re: new/custom php page?
OK - I've tried everything I know of how to get this php search script to work. I've tried embedding it within {php} {/php} tags in the tpl file, but when I do that, it shows a blank page. So, I've had to refrence it as an external file from the tpl file:
Code:
{include_php file="skin1/customer/new/search.php"} |
Re: new/custom php page?
Oh, the logic for everything is this: xcart/mysearch.php --> skin1/customer/mysearch.tpl --> skin1/customer/new/search.php which is the actual code for the search...
|
Re: new/custom php page?
You really shouldn't have .php files in the skin1 directory. What if you moved it to x-cart root/include (except that is where the original search.php is) - can you rename your "new" search.php to mysearch2.php?
|
All times are GMT -8. The time now is 12:56 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.