| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Creating pages with PHP instead of just HTML | ||||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() I've written a PHP application that searches a MySQL database based on the input from the user. Basic stuff, nothing too complicated. It's basically 3 pages, the Search, the Results List and the Details page.
The table I search against can be added to the existing database, that way the system only needs to connect to just one database. I want to integrate this into the X-Cart site I'm building. I want the 3 pages to have all the cart info, navigation, links and other items that are on all the pages. Basically, I just need to use the "content" area. When I added my code to a new page through the "Static Pages" section of X-Cart, none of my PHP code doesn't get executed. I searched these forums but can't find a way to create PHP pages that will fit right into the site like the Static Pages do. Any suggestions? Thanks
__________________
-Mike X-Cart Gold Version 4.2.2 |
|||||||
#2
|
|||||||
|
|||||||
![]() Hello, you need to do several things for this to work.
In the x-cart root you need to add your php files that contain the logic. No display code should be in there. In the php file, you should also have some lines of code similar to this: Code:
Then in skin1/customer/home_main.tpl you will need to add something like this (A good spot is after the {elseif $main eq "subscriptions"} code) Code:
Then you need to make that file and put your design in it. Remember, the design is using smarty and smarty variables. If you need to use {php} tags in the tpl, then you did something wrong. The design will be where the rest of the actual content is. If you need to not show stuff on that page that is, for example, shown on the welcome page then you need to do a little more modification. You may also change the func_display("customer/home.tpl",$smarty); to a different .tpl file with an entirely new design. |
|||||||
|
#4
|
|||||||
|
|||||||
![]() Tal,
What do you mean by "No display code should be in there"?
__________________
X-Cart Gold 4.4.0 |
|||||||
#5
|
|||||||
|
|||||||
![]() Quote:
PHP files are for logic. PHP works with logic faster than smarty. TPL files are for display. Smarty works with templates and caching and such faster than with logic. Performance will drop with php stuff inside TPL files. All the info needed to be displayed should be passed as variables to the TPLs which then format it as needed. So something like below wouldn't be advised in a php file: Code:
Instead it should be: Code:
The reverse is true for TPLs. Bad: Code:
Good: PHP File: Code:
Code:
|
|||||||
#6
|
|||||||
|
|||||||
![]() Thanks, Tal... I understand.
I've read over your reply on this thread and interested in trying to write a small custom mod. I have limited PHP/Smarty skills, but think I have enough to do this. I'm trying to create a shipping request form. It's just like the Contact Us form, but with different fields. The fields will be different sizes, etc. I want to do more than just add additional fields to the contact form. I've experimented with the additional fields and have a basic understanding. The problem is v4.4.0 has a bug with the Contact Us additional fields. They don't get sent with the email that goes out. I've reported this to the Qualiteam bug list. Anyway, I'm trying to create a simple PHP mailer form to send shipping requests to the support department. However, I want it integrated with X-Cart, not a seperate form. I've created advanced mailer forms using PHP code scripts, but I can't get them in X-Cart as their too complicated. The code I use echo's the HTML out and may use more than one PHP file. I've having trouble integrating this into X-Cart using Smarty. Any help from you would be greatly appreciated.
__________________
X-Cart Gold 4.4.0 |
|||||||
#7
|
|||||||
|
|||||||
![]() I would suggest three files.
1) quote.php [Contains any php code that may be required to display, such as pulling variables from the DB. Sets $main and other stuff] 2) quoterequest.php [Contains the mailer. Put in xcart root] 3) quote.tpl [skin1/customer/ and includes the form] quote.php has logic for displaying the page. Sets the $main var. Pushes rest into $smarty quote.tpl shows on quote.php after modification to home_main.tpl. This file also contains the html form which has the action set as quoterequest.php quoterequest.php accepts the vars and sends the mail |
|||||||
#8
|
|||||||
|
|||||||
![]() Ok, I see your logic. However, I don't quite understand how you would access this new page. Would I be creating a static page? How would the web server know to display the new page? Would it be a link something like /home.php?mode=quote ?
__________________
X-Cart Gold 4.4.0 |
|||||||
#9
|
|||||||
|
|||||||
![]() Quote:
quote.php is what is accessed by the user. It will be accessed via http://www.exaple.com/quote.php . In the quote.php file you will need to set the $main var like this: Code:
Then in home_main.php you can set an elseif like this: Code:
So now you got the display working. Also, you may actually want to move the quoterequest.php which sends the email to a different directory such as /include/ so people cant access it directly. |
|||||||
#10
|
|||||||
|
|||||||
![]() Understood... I'm creating a form for the user to enter the data we need. What would the form action be and would the form be in the .tpl file?
__________________
X-Cart Gold 4.4.0 |
|||||||
![]() |
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|