目的:1、实现手机版(wap站)与桌面站处于同一域名下 2、实现页面之间的切换 3、自动识别访问终端,自动切换至相应的版本中
实现思路:编写不同版本(适用于手机、电脑等)的前台模板,通过通过浏览器终端识别函数实现网站版本的正确匹配。页面之间的切换(指用户手动选择不同的网站版本)通过cooki值和网站类别参数来实现网页的终端匹配。
实现步骤:以jtbc的文章模块来说明如何实现
一、程序部分需要做的修改: 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") = "" then 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 b、在函数jtbc_cms_module_detail中加入下面代码
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代码来写!
其他模块与此类同。
网站案例:www.
|