dedecms織夢(mèng)配置手機(jī)wap站點(diǎn),并綁定二級(jí)域名
時(shí)間: 2018-12-06 11:51
閱讀: 次
作者:素材無(wú)憂網(wǎng)
dedecms織夢(mèng)配置手機(jī)wap站點(diǎn),并綁定二級(jí)域名 。
1.安裝手機(jī)wap瀏覽 模塊
2.根目錄創(chuàng)建 wap文件夾 ,將 templets\wap 文件移入 根目錄下的 wap, 如圖:
dedecms 織夢(mèng)配置 手機(jī) wap 站點(diǎn),并綁定二級(jí)域名
3.將根目錄下的 wap.php 移入 wap文件夾,如圖:
dedecms 織夢(mèng)配置 手機(jī) wap 站點(diǎn),并綁定二級(jí)域名
4.修改wap.php
a. 第一行require_once (dirname(__FILE__) . "/include/common.inc.php"); 修改成require_once (dirname(__FILE__) . "/../include/common.inc.php");
b. 第四行require_once(dirname(__FILE__)."/include/wap.inc.php");修改成require_once(dirname(__FILE__)."/../include/wap.inc.php");
c. 第六行 $cfg_templets_dir = $cfg_basedir.$cfg_templets_dir;修改成 $cfg_templets_dir = $cfg_basedir."/wap/".$cfg_templets_dir;
d. 找 到require_once(dirname(__FILE__)."/include/datalistcp.class.php"); 修改成require_once(dirname(__FILE__)."/../include/datalistcp.class.php");
5.文章帶有圖片處理,找到include/wap.inc.php
第54行 $content = str_replace("WAP-IMG::{$k}", $attstr, $content); 修改成 $content = str_replace("WAP-IMG::{$k}", “”, $content);
如果希望讓圖片顯示,您可以修改這個(gè)圖片路徑
6.IIS設(shè)置
a .www.abc.com 下的 wap 文件夾 做重定向
b. 創(chuàng)建新站點(diǎn) wap.abc.com 綁定文件夾 wap
7. 手機(jī)訪問(wèn)www.abc.com 直接跳轉(zhuǎn) wap.abc.com
模板index.htm 添加js
<script src="/tz.php" type="text/javascript"></script>
tz.php 代碼:
<?php
if(isset($_SERVER['HTTP_USER_AGENT']))
{
$clientkeywords = array('nokia','sony','ericsson','mot','samsung','htc','sgh','lg','sharp','sie-','philips','panasonic','alcatel','lenovo','iphone','ipod','blackberry','meizu','android','netfront',
'symbian','ucweb','windowsce','palm','operamini','operamobi','openwave','nexusone','cldc','midp','wap','mobile');
// 從HTTP_USER_AGENT中查找手機(jī)瀏覽器的關(guān)鍵字
if (preg_match("/(".implode('|',$clientkeywords).")/i",strtolower($_SERVER['HTTP_USER_AGENT']))){
?>
<?php
if(isset($_SERVER['HTTP_USER_AGENT']))
{
$clientkeywords = array('nokia','sony','ericsson','mot','samsung','htc','sgh','lg','sharp','sie-','philips','panasonic','alcatel','lenovo','iphone','ipod','blackberry','meizu','android','netfront',
'symbian','ucweb','windowsce','palm','operamini','operamobi','openwave','nexusone','cldc','midp','wap','mobile');
// 從HTTP_USER_AGENT中查找手機(jī)瀏覽器的關(guān)鍵字
if (preg_match("/(".implode('|',$clientkeywords).")/i",strtolower($_SERVER['HTTP_USER_AGENT']))){
?>
window.location.href='http://wap.abc.com';
<?PHP
}
}
?>
8.wap站添加 搜索
修改 wap.php
else if($action=='search')
{
$needCode = 'UTF-8';
if(empty($keyword)) exit('Error!');
require_once(dirname(__FILE__)."/../include/datalistcp.class.php");
$varlist = "cfg_webname,cfg_templeturl";
ConvertCharset($varlist);
$dlist = new DataListCP();
$dlist->SetTemplet($cfg_templets_dir."/wap/search.wml");
$dlist->pageSize = 10;
$dlist->SetParameter("action","search");
$dlist->SetParameter("keyword",$keyword);
$dlist->SetSource("Select id,title,pubdate,click From `idea_archives` where title like '%". iconv("UTF-8", "GB2312",$keyword)."%' And arcrank=0 order by id desc");
$dlist->Display();
exit();
}
標(biāo)簽: