Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

new/custom php page?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-26-2009, 08:20 PM
 
masada3336 masada3336 is offline
 

Senior Member
  
Join Date: Jan 2009
Posts: 115
 

Default 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!!!
__________________
4.4.5 - with Customized Smart Template
Reply With Quote
  #2  
Old 09-27-2009, 07:47 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default 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 echo "hello there"; ?>
Now, in xcart-root/skin1/customer/home.tpl find where it says {include file="help.tpl"}. Copy and paste it (putting a <br /> between the old and new, and then change "help" to "myphp". Clear your templates cache (www.yoursite.com/cleanup.php) and reload the page. "hello there" should appear right after (or before, depending on which instance you modified above) the "News" section.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #3  
Old 09-27-2009, 08:39 AM
 
masada3336 masada3336 is offline
 

Senior Member
  
Join Date: Jan 2009
Posts: 115
 

Default 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!
__________________
4.4.5 - with Customized Smart Template
Reply With Quote
  #4  
Old 09-27-2009, 08:59 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default 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).
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #5  
Old 09-27-2009, 09:10 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default 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.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #6  
Old 09-27-2009, 10:43 AM
 
masada3336 masada3336 is offline
 

Senior Member
  
Join Date: Jan 2009
Posts: 115
 

Default 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 # # $Id: mysearch.php,v 1.5.2.2 2008/04/11 18:09:11 osipov Exp $ # require "./auth.php"; require $xcart_dir."/include/categories.php"; require $xcart_dir."/skin1/mysearch.tpl"; $smarty->assign("_mysearch_",$_new_page_); $smarty->assign("main","_mysearch_"); $smarty->assign("location", $location); $smarty->assign("products",$products); func_display("customer/home.tpl",$smarty); ?>

I flushed my templates, but just for a test my tpl file:
Code:
{* $Id: mysearch.tpl *} test
The result is a page with the error "page not found" in the body area (where I want "test" displayed) and the actual template contents in raw text at the top of the page.

Where am I screwing up?
__________________
4.4.5 - with Customized Smart Template
Reply With Quote
  #7  
Old 09-27-2009, 10:57 AM
 
masada3336 masada3336 is offline
 

Senior Member
  
Join Date: Jan 2009
Posts: 115
 

Default 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!
__________________
4.4.5 - with Customized Smart Template
Reply With Quote
  #8  
Old 09-27-2009, 10:58 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default 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>
try changing "search.php" to "mysearch.php" but I would add our friendly little
Code:
echo "hello there";
to mysearch.php so that it has something (anything) to display and go from there.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #9  
Old 09-27-2009, 11:11 AM
  JWait's Avatar 
JWait JWait is offline
 

X-Man
  
Join Date: Nov 2005
Location: California
Posts: 2,440
 

Default 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.
__________________
Two Separate X-Cart Stores
Version 4.4.4 Gold - X-AOM - Vivid Dreams Aquamarine (modified) - Linux
Mods - Newest Products - View All -, and a few others. Numerous upgrades from 4.0.x series.
Integrated with Stone Edge Order Manager + POS

Version 4.1.12 Gold (fresh install) - X-AOM - Linux
Mods - XCSEO free
Reply With Quote
  #10  
Old 09-27-2009, 11:59 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: new/custom php page?

Quote:
Originally Posted by masada3336
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 # # $Id: mysearch.php,v 1.5.2.2 2008/04/11 18:09:11 osipov Exp $ # require "./auth.php"; require $xcart_dir."/include/categories.php"; require $xcart_dir."/skin1/mysearch.tpl"; $smarty->assign("_mysearch_",$_new_page_); $smarty->assign("main","_mysearch_"); $smarty->assign("location", $location); $smarty->assign("products",$products); func_display("customer/home.tpl",$smarty); ?>

I flushed my templates, but just for a test my tpl file:
Code:
{* $Id: mysearch.tpl *} test
The result is a page with the error "page not found" in the body area (where I want "test" displayed) and the actual template contents in raw text at the top of the page.

Where am I screwing up?

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
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:00 PM.

   

 
X-Cart forums © 2001-2020