2、實現頁面之間的切換
3、自動識別訪問終端,自動切換至相應的版本中
實現思路:編寫不同版本(適用于手機、電腦等)的前臺模板,通過通過瀏覽器終端識別函數實現網站版本的正確匹配。頁面之間的切換(指用戶手動選擇不同的網站版本)通過cooki值和網站類別參數來實現網頁的終端匹配。
實現步驟:以文章模塊來說明如何實現
一、程序部分需要做的修改:
1、把瀏覽器識別函數放入inc.asp(common\incfiles文件夾中)文件中。
2、還是incfiles文件夾打開conn.asp文件,
a、在定義變量 shebei
b、在過程jtbc_cms_setting中加入以下語句(作用記錄網站類型)
If Not request.querystring("site_leixing") = "" Then
response.cookies(appname & "config")("leixing") = request.querystring("site_leixing")
c、在jtbc_cms_init中加入下面語句(把類型參數加入到網址,并剔除重復參數)
nurs = request.ServerVariables("QUERY_STRING")
If not check_null(nurs) and instr(nurs,"site_leixing=0") = 0 and instr(nurs,"site_leixing=1") = 0 then
nurss = "&" & htmlencode(nurs)
else
if instr(nurs,"site_leixing=0") > 0 then
nurss = htmlencode(Replace(nurs,"site_leixing=0",""))
else
nurss = htmlencode(Replace(nurs,"site_leixing=1",""))
end if
end if
3、打開incfiles文件中的module_config.asp文件,把函數jtbc_cms_module_index成如下(首頁的切換代碼)
dim tmpstr
If Not request.cookies(appname & "config")("leixing") = "" then
shebei= request.cookies(appname & "config")("leixing")
if shebei = 1 then
tmpstr = ireplace("module.sm_index", "tpl")
else
tmpstr = ireplace("module.index", "tpl")
end if
else
dim shebei1:shebei1=websitez_detect_mobile_device()
if shebei1(0) = true then
tmpstr = ireplace("module.sm_index", "tpl")
else
tmpstr = ireplace("module.index", "tpl")
end if
end if
jtbc_cms_module_index = tmpstr
4、打開article\common\incfiles文件中的module_config.asp文件
a、在函數jtbc_cms_module_list中加入如下代碼
If Not request.cookies(appname & "config")("leixing") = "" thenb、在函數jtbc_cms_module_detail中加入下面代碼
shebei= request.cookies(appname & "config")("leixing")
if shebei = 1 then
tmpstr = itake("module.sm_list", "tpl")
else
tmpstr = itake("module.list", "tpl")
end if
else
dim shebei1:shebei1=websitez_detect_mobile_device()
if shebei1(0) = true then
tmpstr = itake("module.sm_list", "tpl")
else
tmpstr = itake("module.list", "tpl")
end if
end if
If Not request.cookies(appname & "config")("leixing") = "" then
shebei= request.cookies(appname & "config")("leixing")
if shebei = 1 then
tmpstr = itake("module.sm_detail", "tpl")
else
tmpstr = itake("module.detail", "tpl")
end if
else
dim shebei1:shebei1=websitez_detect_mobile_device()
if shebei1(0) = true then
tmpstr = itake("module.sm_detail", "tpl")
else
tmpstr = itake("module.detail", "tpl")
end if
end if
至此程序代碼部分完成
二、前臺html代碼部分
1、進入后臺-> 系統管理->模板管理-> 首頁模板:添加節點sm_index
2、頭尾模板:添加節點sm_head、sm_foot
3、文章管理->前臺模板:添加sm_list、sm_detail
說面以上所加節點中的前臺代碼只要符合手機瀏覽器規范即可,一般用XHTML或HTML5文檔。其他與電腦版html文件一致、不在一一添加累述。具體寫法可參照別的手機網站的html代碼來寫!
其他模塊與此類同。