| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Simple Guide to Creating Basic PHP Pages using Templates | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
Simple Guide to Creating Basic PHP Pages using Templates
I originally wrote this for my blog - but I thought I would share - I had a hard time finding this information how through the forums so I here we go a new thread.
I don't know if I just missed the section that details how to create a PHP page in X-cart so I finally just broke down and decided to write this article. Here was my scenario - I wanted to create a static PHP page that could access from the x-cart site root. I also wanted the page to use the main template design for the site - so things like shopping cart totals and customer login info were still being displayed. Things to know: 1.) X-Cart uses SMARTY template engine - I can't stand it - but whatever. 2.) X-Cart uses a directory structure that keeps all template files in one location (yourroot/skin1/) 3.) PHP scripts are executed from outside of this /skin1/ directory - try using a the folder called Modlues and add your custom file there. 4.) The logic for creating a template is: yournewpage.php --> skin1/customer/home_main.tpl --> include customer/yournewpage.tpl --> skin1/customer/yournewpage.tpl I create sitemap.php as my example. 1.) Lets create sitemap.php Code:
If you look at the last line - we just captured all of the necessary SMARTY variables and shoved them into the "customer/home.tpl" - this template calls another template into the center content area of your page "customer/home_main.tpl" So lets alter the "customer/home_main.tpl" page - towards the last line include this just before the final "else" statement Code:
Ok - so now we are injecting the "customer/sitemap.tpl" into the main content area of our web page - with all the fancy design we spent so long to perfect. So lets create and add some content to the "customer/sitemap.tpl" in our /skin1/ directory Code:
On this page we used some standard x-cart variables to display Categories and Subcategories - from here you can extend it to include template variables so you can even more granular control. - example try adding a language variable to the code just after the last SMARTY include line Code:
Like I mentioned before you can keep extending this to include simple includes to other templates such as a template to where PHP can bve executed - such as in the Modules directory outside of /skin1/ Code:
I hope this helps - if you know of a better place to find this documentation - would you please let me know.
__________________
------ Brian Portland web design / development X-Cart 4.1.9 (a few carts) X-Cart 4.2.0 (1 cart so far) |
|||||||||
#2
|
|||||||||
|
|||||||||
Re: Simple Guide to Creating Basic PHP Pages using Templates
PS - this is also a pretty helpful post for those looking to create a Sitemap Page with automatic Categories and Subcategories.
For an XML sitemap I always recommend WebSiteCM CDSEO Pro - amazing.
__________________
------ Brian Portland web design / development X-Cart 4.1.9 (a few carts) X-Cart 4.2.0 (1 cart so far) |
|||||||||
#3
|
|||||||
|
|||||||
Re: Simple Guide to Creating Basic PHP Pages using Templates
This is all sorts of awesome - v. helpful, thanks for sharing.
__________________
X-Cart Pro 4.4 |
|||||||
|
|||
X-Cart forums © 2001-2020
|