很多用戶對(duì)zen cart做了自己的修改,非常好!但同時(shí),一些用戶修改了很多重要的文件,例如:
/includes/filenames.php
/includes/languages/schinese.php
/includes/languages/schinese/*.php
等等…
友情提示:如果你希望以后的升級(jí)更容易,不要修改這些文件!
Zen Cart的文件替代機(jī)制的功能非常強(qiáng),你不需要修改上面的這些文件。
如果你修改了這些文件,下次升級(jí)的時(shí)候,Zen Cart會(huì)覆蓋這些文件,你做的修改會(huì)丟失。
好了,如何避免這種情況呢?如何使用文件替代機(jī)制?
下面,我一步步說明如何使用文件替代機(jī)制,而不是去修改Zen Cart的核心文件!
下面的所有例子,都假設(shè)你:
1. 使用簡(jiǎn)體中文。其它語(yǔ)言相應(yīng)修改就好。
2. 例子使用的模板名字是custom
“custom” 目錄名可以是任何名字…. 只是在所有地方都要一致,這樣文件替代機(jī)制才能正常工作。
你可以命名為:
– mytemplate
– custom
– billg
– helluvacart
– zenrocks
– thisseemstoolongatemplatename
– supercalifragilisticexpialidocious
– tpl
還有很多 !!!!
附錄及聲明: 如果我漏了什么, 或者說錯(cuò)了,請(qǐng)告知,我會(huì)盡快修改! 不作任何擔(dān)保。一個(gè)月后憑收據(jù)退款!
– 注,請(qǐng)先閱讀-如何添加/建立新的模板?
================================
修改缺省語(yǔ)言文件 – /includes/languages/schinese.php
例子: 你想修改標(biāo)題,將“Zen Cart!”, 改為“我的商店名稱!”
在目錄/includes/languages下,建立一個(gè)與你的模板同名的目錄,例如/includes/languages/custom.
將schinese.php文件復(fù)制到該目錄。
接著,你就可以修改文件/includes/languages/custom/schinese.php:
define(’TITLE’, ‘Zen Cart!’);
改為:
define(’TITLE’, ‘我的商店名稱!’);
================================
修改語(yǔ)言文件 – /includes/languages/schinese/*.php (所有該目錄下的文件)
例子: 你想修改account.php中的文字 – 比如你要將 ‘帳號(hào)’ 改為 ‘檔案’
建立一個(gè)與你的模板同名的目錄。假設(shè)模板名是custom。那么目錄就是:
/includes/languages/schinese/custom
將原來的文件/includes/languages/schinese/account.php復(fù)制到新目錄:
/includes/languages/schinese/custom
接著, 修改該新的custom目錄下的文件。這樣,該修改會(huì) ‘替代’ 原來/includes/languages/schinese目錄中的相應(yīng)文件, 從而不會(huì)影響和修改核心文件。
================================
修改模板文件 – /includes/templates/template_default/templates/tpl_*_default.php
例如: 你想修改tpl_account_default.php文件中的一些HTML
在你的模板目錄中( /includes/templates/custom ) 你應(yīng)該已經(jīng)有一個(gè)模板目錄了 ( /includes/templates/custom/templates )。
將文件tpl_account_default.php復(fù)制到該目錄中。然后你就可以自己修改了,它會(huì)自動(dòng) ‘替代’ /includes/templates/template_default/templates目錄中的相應(yīng)文件。
你只要復(fù)制需要修改的文件到自己的模板目錄,如果你未做修改,那么缺省情況下,商店會(huì)從template_default目錄調(diào)用缺省文件。
================================
修改邊框模板
這和修改通用模板是一樣的(見上), 除了邊框的路徑是:
/includes/templates/custom/sideboxes
================================
修改邊框 – /includes/modules/sideboxes/*.php
例子: 你想修改邊框information.php文件,加上另外一個(gè)鏈接。
在邊框文件的目錄中(/includes/modules/sideboxes),建立另一個(gè)和模板custom同名的子目錄,就是/includes/modules/sideboxes/custom
將文件information.php復(fù)制到該新目錄中
接著你就可以修改新的information.php,它會(huì)替代/includes/modules/sideboxes目錄中的缺省information.php文件
你可以核對(duì)該邊框是否被替代,登錄管理頁(yè)面 -> 工具 -> 外觀控制。在欄目 ‘方框文件名’ 下, 如果文件名顯示為紅色, 就說明它被替代了。
================================
調(diào)用自定義文件名 – /includes/filenames.php
例子: 你新建了一個(gè)頁(yè)面about_us,需要調(diào)用該文件名。
不要在/includes/filenames.php文件中添加一個(gè)新的定義,你應(yīng)該在已有的目錄/includes/extra_datafiles中定義該文件名。
建立新文件about_us_filenames.php,然后放在目錄/includes/extra_datafiles中。
在該文件中,要有以下代碼:
代碼: 全選
// About Us Filename Define
##define(’FILENAME_ABOUT_US’, ‘about_us’);
?>
該文件將自動(dòng)被調(diào)用, 就象該目錄中的其它文件一樣, 因此系統(tǒng)知道你的定制文件。
盡量用同樣的辦法新建文件…例如, 調(diào)用文件blah,將它命名為blah_filenames.php
================================
調(diào)用自定義數(shù)據(jù)庫(kù)表 – /includes/database_tables.php
例子: 你為自己的UPS跟蹤系統(tǒng)建了個(gè)數(shù)據(jù)庫(kù)ups_track,需要為代碼定義數(shù)據(jù)表名。
不要在文件/includes/database_tables.php中定義, 你要在已有的目錄/includes/extra_datafiles中定義數(shù)據(jù)表。
建立新文件ups_track_database_tables.php,置于目錄/includes/extra_datafiles中。
在該文件中,要有以下代碼:
代碼: 全選
// UPS Tracking Table
##define(’TABLE_UPS_TRACK’, ‘ups_track’);
?>
該文件將自動(dòng)被調(diào)用,就象該目錄中的其它文件一樣, 因此系統(tǒng)知道你的定制數(shù)據(jù)庫(kù)。
================================
額外語(yǔ)言文件
例如: 你新建了一個(gè)Resource Center方框,需要一個(gè)額外文件來調(diào)用額外語(yǔ)言定義。
在目錄/includes/languages/schinese/extra_definitions中, 你可以建立一個(gè)文件resource_center_box_defines.php。在該文件中,你可以放置新的方框的所有語(yǔ)言定義。
該文件將自動(dòng)被調(diào)用, 保證你的自定義方框或頁(yè)面的語(yǔ)言定義被調(diào)用。
================================
給已有文件增加額外Javascript
例子: 你想為你的Bizrate帳號(hào)調(diào)用一些javascript,這樣,訂單完成后,就會(huì)從已有頁(yè)面調(diào)用checkout_success.php。
在目錄/includes/modules/pages/checkout_success中,建一個(gè)新文件jscript_bizrate.js
在該文件中,放置Bizrate給你的javascript代碼,例如:
代碼: 全選
同樣地..如果你使用Google的轉(zhuǎn)換跟蹤系統(tǒng)。建立另外一個(gè)文件,例如jscript_google.php
================================
添加和修改CSS文件
例子: 你為自己的網(wǎng)站新建了一個(gè)CSS類
不要添加到已有的CSS文件/includes/templates/custom/css/stylesheet.css中,要在同一目錄下,另建一個(gè)文件stylesheet_YOURFILENAME.css,然后將你的CSS數(shù)據(jù)加在這里。
================================
最后,談?wù)勆?jí)!
現(xiàn)在,你正確使用Zen Cart的替代機(jī)制了!恭喜,你可以放心了。你不用擔(dān)心升級(jí)文件會(huì)覆蓋你的定制文件,因?yàn)樗械亩ㄖ莆募急4嬖谀阕约旱哪夸浝铮?/span>
好吧,你升級(jí)了Zen Cart。但如果你替代的文件有新的代碼呢?所以你需要比較custom目錄和新的核心文件。
例子:你修改了/includes/languages/custom/schinese.php文件, 升級(jí)后, /includes/languages/schinese.php文件中有些新的定義。顯然你要把這些新的定義加入到你的schinese.php文件中。
最容易的方法就是使用文件比較工具!
推薦使用WinMerge, 也是開源免費(fèi)。
有了文件比較工具,你就可以比較你的/includes/languages/custom/schinese.php文件, 和新的核心文件/includes/languages/schinese.php,然后很容易將新的修改加入到你的替代文件中。
文件路徑 注釋
index.php 主文件
includes/templates/[custom template folder]/common/html_header.php 頁(yè)面的head部分
includes/templates/[custom template folder]/common/tpl_main_page.php 頁(yè)面的body部分
includes/templates/[custom template folder]/common/tpl_header.php 所有頁(yè)面的頁(yè)眉
(column left)
includes/templates/[custom template folder]/common/main_template_vars.php 決定頁(yè)面的內(nèi)容部分,缺省為 ‘tmp_index_default.php’
首頁(yè) – 缺省
includes/templates/[custom template folder]/templates/tmp_index_default.php 首頁(yè)模板文件
首頁(yè) – 顯示分類
includes/templates/[custom template folder]/templates/tpl_index_categories.php 首頁(yè)上顯示分類時(shí)的模板文件
includes/modules/[custom template folder]/pages/index/category_row.php 選擇要顯示的分類
includes/templates/[custom template folder]/templates/tpl_index_category_row.php 顯示分類
首頁(yè) – 顯示指定分類
includes/templates/[custom template folder]/templates/tpl_index_product_list.php 首頁(yè)上顯示指定的分類時(shí)采用的模板文件
includes/modules/[custom template folder]/product_listing.php 將商品數(shù)據(jù)添加到數(shù)組
includes/templates/[custom template folder]/templates/tpl_modules_product_listing.php 顯示商品數(shù)量和商品導(dǎo)航菜單
includes/templates/[custom template folder]/common/tpl_list_box_content.php 顯示商品數(shù)組
商品信息頁(yè)面
includes/templates/[custom template folder]/templates/tpl_product_info_display.php 顯示單件商品信息
購(gòu)物車頁(yè)面
includes/templates/[custom template folder]/templates/tpl_shopping_cart_default.php 購(gòu)物車頁(yè)面
(column right)
includes/templates/[custom template folder]/common/tpl_footer.php 所有頁(yè)面的頁(yè)腳