婴儿dpb是什么病:[转存]osCommerce简单模板制作系统STS(Simple Template Sys...

来源:百度文库 编辑:中财网 时间:2024/05/10 19:42:59
osCommerce简单模板制作系统STS(Simple Template System)2007年07月26日 星期四 上午 00:05目录
1. 插件简介 1
2. STS的原理 2
3. STS 安裝 3
4. 使用STS模板系统 6
5. 参考 10
6. 对STS的评价 14

本插件可以让你轻易的利用设计好的HTML模板文件来控制osCommerce的首页版面的外观。达到轻松定制你的osCommerce的效果。你可以将版面上的各个Box模块放在HTML文件的不同的位置上,首页就会立即将你的修改显示出来。

1. 插件简介

STS是Simple Template System的缩写,翻译成中文的意思是“简单模板系统”。软件系统的主题,或者叫做布景(Theme),对于许多使用过phpNuke或者是Xoops的人都是十分的熟悉,布景对于这些建站系统来说已经有了完美的支持。但是对于osCommerce系统,根据开发计划,在Mile Stone 3(目前是 Mile Stone 2) 时才会支持基本的模板系统,也就是说可能要在 osCommerce 2.3 或 3.0 以后才会出现布景系统 (Theme),所以,如果要使用系统默认的布景功能,还需要等待一定的时间。
因此,在官方的外挂插件(contributions)中,有两个模板功能的插件,对于osCommerce的阳春版面来说,是一个重新打造外观的最好选择。其中之一就是我们本文所提到的STS系统,另外一个时BTS(Basic Template System),我们会在另外进行介绍。

2. STS的原理

STS的原理非常简单,使用一个标准的HTML文件(sts_template.html),更简单的说,你只需要会的样式,包括颜色,背景,对齐等属,就可以立即得到不一样的版面。同样,对于常见的问题,“如何将底部的Banner移到上区域中?”,使用STS就可以将一切搞定。
目前STS提供了丰富的变量可以进行版面设计工作,导STS 2.01为止,甚至可以针对某一商品的分类或者某一商品制作特定的模板(template),预计以后会有更多的功能。

3. STS 安裝

STS的安装相当简单,作者的说明文档中提供了两种安装方法,分别是干净的osCommerce安装和修改过的osCommerce安装,所谓干净的安装是指osCommerce软件是从官方网站上下载,并且没有安装任何的插件的情况下进行的安装,对于安装了任何的插件模块,需要按照第二中方法进行安装。

第一步:下载STS插件

请直接导官方网站http://oscommerce.sunsite.dk/contributions/STS-2_01.zip 或 http://www.oscommerce.com/contributions/STS-2_01.zip 下载软件到本地电脑,使用解压工具将文件解开。

第二步:备份原始文件

安装前请备份catalog/includes目录下的文件:
application_top.php
configure.php
header.php
column_left.php
column_right.php
footer.php
application_bottom.php
如果是远程的主机,需要将这几个文件下载到你自己的电脑上。

第三步:编辑STS的application_top.php文件,在最后一行 ?> 之前插入下列代码:

代码:
// STS: ADD
// Capture text between application_top.php and header.php
require(STS_START_CAPTURE);
// STS: EOADD

第四步:编辑configure.php文件,再文件的最后一行 ?> 之前增加如下代码:

代码:
// STS: ADD: Define Simple Template System files
define('STS_START_CAPTURE', DIR_WS_INCLUDES . 'sts_start_capture.php');
define('STS_STOP_CAPTURE', DIR_WS_INCLUDES . 'sts_stop_capture.php');
define('STS_RESTART_CAPTURE', DIR_WS_INCLUDES . 'sts_restart_capture.php');
define('STS_TEMPLATE_DIR', DIR_WS_INCLUDES . 'sts_templates/');
define('STS_DEFAULT_TEMPLATE', DIR_WS_INCLUDES . 'sts_template.html');
define('STS_DISPLAY_OUTPUT', DIR_WS_INCLUDES . 'sts_display_output.php');
define('STS_USER_CODE', DIR_WS_INCLUDES . 'sts_user_code.php');
define('STS_PRODUCT_INFO', DIR_WS_INCLUDES . 'sts_product_info.php');
// STS: EOADD

第五步:如果服务器再远程,使用更新工具上传你的文件。

第六步:使用浏览器打开osCommerce,如果可以正常浏览到网站,证明安装成功。

第七步:尝试修改catalog/includes/sts_template.html内的参数,可以使用dreamweaver 之类的编辑器打开文件,进行修改。

提示:如果安装失败,只需要将你备份的文件恢复即可。

干净模式的安装

安装之前同样需要备份上面提到的文件,然后将下列文件复制到include目录下即可:
application_top.php
header.php
column_left.php
column_right.php
footer.php
application_bottom.php
sts_start_capture.php
sts_stop_capture.php
sts_restart_capture.php
sts_display_output.php
sts_user_code.php
sts_template.html
configure-SAMPLE.php
说明: configure-SAMPLE.php 文件是一个范例文件,他说明了如何修改configure.php文件,修改主目录下的/includes/configure.php在最后一行 ?> 之前,插入下面的程序代码:
代码:
// STS: ADD: Define Simple Template System files
define('STS_START_CAPTURE', DIR_WS_INCLUDES . 'sts_start_capture.php');
define('STS_STOP_CAPTURE', DIR_WS_INCLUDES . 'sts_stop_capture.php');
define('STS_RESTART_CAPTURE', DIR_WS_INCLUDES . 'sts_restart_capture.php');
define('STS_TEMPLATE_DIR', DIR_WS_INCLUDES . 'sts_templates/');
define('STS_DEFAULT_TEMPLATE', DIR_WS_INCLUDES . 'sts_template.html');
define('STS_DISPLAY_OUTPUT', DIR_WS_INCLUDES . 'sts_display_output.php');
define('STS_USER_CODE', DIR_WS_INCLUDES . 'sts_user_code.php');
define('STS_PRODUCT_INFO', DIR_WS_INCLUDES . 'sts_product_info.php');
// STS: EOADD

注意: 不要修改admin/目录下的文件。

4. 使用STS模板系统

你可以用你喜欢的网页编辑软件,打开并修改主目录的/includes/sts_template.html 文件。

如果你想要加入新的函数区域或者样本参数,把它加入 sts_user_code.php 文件中。但如果你将拉升级这个插件,一定要记住,不能够覆盖这个文件,需要使用手工修改的方式。

为每一个页面设计一个模板文件(1.8版以后支持)

你可以为每一个档案都设计一个模板文家,方法如下:
1. 在osCommerce程序主目录下建一个名称为/includes/sts_templates/的文件夹
2. 将你的模板名称命名为xxx.php.htm
例如,你要专门针对index.php 建立一个模板文件,那么这个文件的名称就叫做/includes/sts_templates/index.php.html
3. 由于文件的名称已经改为.htm文件,所以服务器不会把它当作程序来执行
4. 如果没有找到对应的模板文件,那么系统会使用STS_DEFAULT_TEMPLATE这个文件来取代

为每一个主类别生成一个模板文件(2.0版本以后支持)

你可以为从首页进入的每一个主类别都设计一个模板文件。
1) 首页的模板文件是:
程序根目录的/includes/sts_template.html
2) 主类别的默认模板文件是:
根目录/includes/sts_templates/index.php.html
3) 各类别的模板文件:
以第二各类别为例,网址是index.php?cPath=2 ,那么对应的文件的名称就是
根目录/includes/sts_templates/index.php_2.html
4) 假设类别的网址是index.php?cPath=XX_YY ,那么对应的模板文件名字就是:
根目录/includes/sts_templates/index.php_XX-YY.html

产品信息模板(2.0版以后支持)

模板名称和位置如下:
根目录/includes/sts_templates/product_info.php.html
你可以修改项目参数和页面风格,所有参数在后面列出。
在下载的插件中,有一个叫做product_info.php.html-SAMPLE 的文件,这是一个例子,虽然设计的不是十分好看,但是可以作为参考。如果你要用它,需要将这个文件保存到相应的位置,并重新命名。

如何加入其他插件到首页的模板中? (以『首页登陆插件』为例)

首先完成『首页登陆插件』的安装。
这个插件可以从http://www.oscommerce.com/community/contributions,857上下载。
然后打开/includes/sts_template.html 这个文件,在你想要增加这个插件的地方加入$loginbox 。

然后编辑/includes/sts_user_code.php 文件,在最后一行php程序代码结束符号" ?>" 之前,插入下面的代码:
$sts_block_name = 'loginbox';
require(STS_START_CAPTURE);
require(DIR_WS_BOXES . 'login.php');
require(STS_STOP_CAPTURE);
$template['loginbox'] = strip_unwanted_tags($sts_block['loginbox'], 'loginbox');
结果显示如下:

结论:我们不需要修改includes/column_right.php 或 includes/column_left.php这两个文件,而是应该修改sts_user_code.php这个文件。
使用技巧
在你的模板文件的图片和样式表达上,尽量使用绝对的URL地址表示方法。

5. 参考

这里可以找到使用本插件的网站列表
http://www.diamondsea.com/sts/sites.html
插件地址:
http://www.oscommerce.com/community/contributions,1524
英文讨论区:
http://forums.oscommerce.com/index.php?showtopic=58541

调试
In the /catalog/includes/sts_display_output.php file you can see the
following settings (near the top of the file):

$display_template_output = 1;
$display_normal_output = 0;
$display_debugging_output = 0;

Display_Template_Output (the default setting) will cause it to display the
template versions of the pages.

Display_Normal_Output will cause it to display the non-template version of
the pages.

Display_Debugging_Output will cause it to display debugging information
showing all of the blocks of data that it is using and how it translates
them into template variables as well as some other runtime details.

You can use any or all of the settings in any combination. If you have both
Normal and Template output, the Template output will be displayed first.
 
远程调试
You can toggle the debugging options via URL options. You can use the
following parameters in your URL to turn on/off options from your browser

sts_template=1 Turns on the Template display
sts_template=0 Turns off the Template display
sts_normal=1 Turns on the Normal display
sts_normal=0 Turns off the Normal display
sts_debug=1 Turns on the Debugging display
sts_debug=0 Turns off the Debugging display
sts_version=1 Turns on Version Number display
sts_version=0 Turns off Version Number display

6. 对STS的评价

首先,STS安装和使用很简便,操作容易,定制功能强大,基本满足了我们的需要。
但是,需要使用者有HTML设计经验,商业用户使用的时候带来了一定的难度,如果为他做一个定性的评价:
功能:4(5分制)
安装时间:5分钟
难度:3(5分制)1->5由易到难
等的 HTML的基本标记的用法就可以把 osCommerce原来的版面修改成另外一个样子,进行个性化的设计。
以osCommerce的基本版面来说,分成五个区域,包含:上,左,中,右和下区域,在STS系统中,将每个区域再进行细分,将细分的功能抽出来变成一个独立的参数。以上区域为例,我们可以看到这个区域内包括:Logo图片连接,我的帐户,购物车,内容以及结帐三个图片连接,导览列。因此,再STS系统中,一一对应了参数:$cataloglogo、$myaccountlogo、$cartlogo、$checkoutlogo、$breadcrumbs。有了这些参数,可以将Logo放到osCommerce系统版面的任何地方,不需要修改任何的osCommerce源码文件,对于不懂PHP的人最为适合,也是osCommerce现在定制修改的最佳方式。
看一下例子:
代码:







$cataloglogo $myaccountlogo $cartlogo $checkoutlogo






$breadcrumbs $myaccountlogoff | $cartcontents | $checkout



这是一个最简单的HTML文件,但却可以表现出osCommerce基本版本的上区域部分,而且只需要修改参数的位置或者改变