![]() |
|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
#1
IP: 153.99.38.207
|
|||
|
|||
|
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:
<?php
#
# $Id: sitemap.php,v 1.0 2010/01/11 18:09:11 pdma Exp $
#
require "./auth.php";
require $xcart_dir."/include/categories.php";
$smarty->assign("_sitemap_",$_new_page_);
$smarty->assign("main","_sitemap_");
func_display("customer/home.tpl",$smarty);
?>
So lets alter the "customer/home_main.tpl" page - towards the last line include this just before the final "else" statement Code:
{elseif $main eq "_sitemap_"}
{include file="customer/sitemap.tpl"}
So lets create and add some content to the "customer/sitemap.tpl" in our /skin1/ directory Code:
{*
$Id: sitemap.tpl,v 1.0 2010/01/11 09:52:43 pdma Exp $
vim: set ts=2 sw=2 sts=2 et:
*}
{capture name=menu}
{if $active_modules.Fancy_Categories}
{include file="modules/Fancy_Categories/categories.tpl"}
{assign var="additional_class" value="menu-fancy-categories-list"}
{else}
{assign var=thiscat value=$cat}
{assign var=par value=0}
{foreach from=$categories item=cats}
{assign var=Mcatid value=$cats.categoryid}
{foreach from=$allsubcategories.$Mcatid item=subb}
{if $subb.categoryid eq $thiscat}
{assign var=par value=$subb.parentid}
{/if}
{/foreach}
{/foreach}
{foreach from=$categories_menu_list item=c}
<h2><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}">{$c.category}</a></h2>
{assign var=in value=$c.categoryid}
<ul>
{foreach from=$allsubcategories.$in item=cat}
{if $cat.parentid eq $c.categoryid}
<li><a href="home.php?cat={$cat.categoryid}" class="subMenuItem">{$cat.category}</a></li>
{/if}
{/foreach}
</ul>
{/foreach}
{assign var="additional_class" value="menu-categories-list"}
{/if}
{/capture}
{include file="customer/menu_dialog.tpl" title=$lng.lbl_categories content=$smarty.capture.menu}
- example try adding a language variable to the code just after the last SMARTY include line Code:
{$lng.lbl_shopinfo}
Code:
{include_php file="modules/Sitemap/sitemap.php"}
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| X-Cart Multiple Input Validation Holes Permit SQL Injection and Cross-Site Scripting | topvip | X-Cart | 0 | 2009-07-21 10:03 AM |
| 用php语言来编写shell脚本 | car | 代码交流 | 0 | 2008-05-05 08:09 PM |
| Php教程.经验技巧(上) | sunshine | 代码交流 | 0 | 2006-12-15 08:13 PM |
| Php入门速成 | smiling | 代码交流 | 0 | 2006-12-15 07:30 PM |
| php.ini中文解释 | sunshine | 服务器环境搭建 | 0 | 2006-02-04 11:05 PM |