婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 網站建設 > 建站知識 > dedecms織夢系統生成wap手機版靜態頁完整版

dedecms織夢系統生成wap手機版靜態頁完整版

POST TIME:2017-11-13 00:39

打開include目錄下的common.inc.php,在26行加入代碼:

define('DEDEWAPPATH','/wap');//生成手機版靜態頁目錄

define('DEDEWAPTEMPLATESPATH','/wap/');//手機版模板目錄templets







首先創建手機版的文章模板,這里自己創建,跟其他模板一樣,不過保存路徑/templets/wap/article_article.htm

























首先找到include目錄下的arc.archives.class.php,修改文件前最好備份一下,找到函數function MakeHtml($isremote=0),函數最后一行代碼438行修改一如下:

$returl=$this->GetTrueUrl($filename);

$this->MakeWapHtml($isremote);

return $returl;








在442行增加函數代碼

function MakeWapHtml($isremote=0)

{

global $cfg_df_style,$cfg_arcdir;

$tempfile = $this->GetTempletFile();

$tempfile = str_replace('/' . $cfg_df_style . '/',DEDEWAPTEMPLATESPATH,$tempfile);

if(!file_exists($tempfile) || !is_file($tempfile))

{

}else{

global $cfg_remote_site,$fileFirst;

if($this->IsError)

{

return '';

}

$this->Fields["displaytype"] = "st";

//預編譯$th

$this->dtp->LoadTemplate($tempfile);

$this->TempSource = $this->dtp->SourceString;

$this->ParAddTable();

$this->ParseTempletsFirst();

$this->Fields['senddate'] = empty($this->Fields['senddate'])? '' : $this->Fields['senddate'];

$this->Fields['title'] = empty($this->Fields['title'])? '' : $this->Fields['title'];

$this->Fields['arcrank'] = empty($this->Fields['arcrank'])? 0 : $this->Fields['arcrank'];

$this->Fields['ismake'] = empty($this->Fields['ismake'])? 0 : $this->Fields['ismake'];

$this->Fields['money'] = empty($this->Fields['money'])? 0 : $this->Fields['money'];

$this->Fields['filename'] = empty($this->Fields['filename'])? '' : $this->Fields['filename'];

//分析要創建的文件名稱

$filename = GetFileNewName(

$this->ArcID,$this->Fields['typeid'],$this->Fields['senddate'],

$this->Fields['title'],$this->Fields['ismake'],$this->Fields['arcrank'],

$this->TypeLink->TypeInfos['namerule'],$this->TypeLink->TypeInfos['typedir'],$this->Fields['money'],$this->Fields['filename']

);

$filename=str_replace($cfg_arcdir .'/',DEDEWAPPATH .'/',$filename);

$filenames = explode(".", $filename);

$this->ShortName = $filenames[count($filenames)-1];

if($this->ShortName=='') $this->ShortName = 'html';

$fileFirst = preg_replace("/\.".$this->ShortName."$/i", "", $filename);

$this->Fields['namehand'] = basename($fileFirst);

$filenames = explode("/", $filename);

$this->NameFirst = preg_replace("/\.".$this->ShortName."$/i", "", $filenames[count($filenames)-1]);

if($this->NameFirst=='')

{

$this->NameFirst = $this->arcID;

}

//獲得當前文檔的全名

$filenameFull = GetFileUrl(

$this->ArcID,$this->Fields['typeid'],$this->Fields["senddate"],

$this->Fields["title"],$this->Fields["ismake"],

$this->Fields["arcrank"],$this->TypeLink->TypeInfos['namerule'],$this->TypeLink->TypeInfos['typedir'],$this->Fields["money"],$this->Fields['filename'],

$this->TypeLink->TypeInfos['moresite'],$this->TypeLink->TypeInfos['siteurl'],$this->TypeLink->TypeInfos['sitepath']

);

$this->Fields['arcurl'] = $this->Fields['fullname'] = $filenameFull;

//對于已設置不生成HTML的文章直接返回網址

if($this->Fields['ismake']==-1 || $this->Fields['arcrank']!=0 || $this->Fields['money']>0

|| ($this->Fields['typeid']==0 && $this->Fields['channel'] != -1) )

{

return $this->GetTrueUrl($filename);

}

//循環生成HTML文件

else

{

for($i=1;$i<=$this->TotalPage;$i++)

{

if($this->TotalPage > 1) {

$this->Fields['tmptitle'] = (empty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle']);

if($i>1) $this->Fields['title'] = $this->Fields['tmptitle']."($i)";

}

if($i>1)

{

$TRUEfilename = $this->GetTruePath().$fileFirst."_".$i.".".$this->ShortName;

}

else

{

$TRUEfilename = $this->GetTruePath().$filename;

}

$this->ParseDMFields($i,1);

if(!is_dir(dirname($TRUEfilename))) {

mkdir(dirname($TRUEfilename), 0777, true);

}

$this->dtp->SaveTo($TRUEfilename);

//如果啟用遠程發布則需要進行判斷

if($cfg_remote_site=='Y' && $isremote == 1)

{

//分析遠程文件路徑

$remotefile = str_replace(DEDEROOT, '', $TRUEfilename);

$localfile = '..'.$remotefile;

//創建遠程文件夾

$remotedir = preg_replace("#[^\/]*\.html#", '', $remotefile);

$this->ftp->rmkdir($remotedir);

$this->ftp->upload($localfile, $remotefile, 'ascii');

}

}

}

$this->TempSource=='';

}

}

















wap模板中調用頭部和底部文件需要修改

找到include目錄文件dedetag.class.php中大概1013行的函數

function IncludeFile

else{

return "無法在這個位置找到: $filename";

}

前加

else if(file_exists(DEDEROOT.'/templets'.DEDEWAPTEMPLATESPATH.$filename) )

{

$okfile = DEDEROOT.'/templets'.DEDEWAPTEMPLATESPATH.$filename;

}

注意wap模板的頭文件不要與pc頭文件名相同,如用wap_header.htm和wap_footer.htm
























欄目頁生成html

首先找到include目錄下的arc.listview.class.php,修改文件前最好備份一下,找到143行function CountRecord

給函數加一個參數修改成function CountRecord($iswap=0)

并在函數中229行 if(!file_exists($tempfile))前加入代碼

if($iswap==1){

$tempfile = str_replace('/'.$GLOBALS['cfg_df_style'].'/',DEDEWAPTEMPLATESPATH,$tempfile);

}


















function MakeHtml($startpage=1, $makepagesize=0, $isremote=0)

把最后面373行

return $murl;修改成

$reurl=$murl;

$this->MakeWapHtml($startpage, $makepagesize, $isremote);

return $reurl;










377行添加函數MakeWapHtml

代碼如下

function MakeWapHtml($startpage=1, $makepagesize=0, $isremote=0)

{

global $cfg_remote_site,$cfg_arcdir;

if(empty($startpage))

{

$startpage = 1;

}

//創建封面模板文件

if($this->TypeLink->TypeInfos['isdefault']==-1)

{

echo '這個類目是動態類目!';

// return '../plus/list.php?tid='.$this->TypeLink->TypeInfos['id'];

}

//單獨頁面

else if($this->TypeLink->TypeInfos['ispart']>0)

{

$reurl = $this->MakePartTemplets();

// return $reurl;

}

$this->CountRecord(1);

//初步給固定值的標記賦值

$this->ParseTempletsFirst();

$totalpage = ceil($this->TotalResult/$this->PageSize);

if($totalpage==0)

{

$totalpage = 1;

}

CreateDir(MfTypedir($this->Fields['typedir']));

$murl = '';

if($makepagesize > 0)

{

$endpage = $startpage+$makepagesize;

}

else

{

$endpage = ($totalpage+1);

}

if( $endpage >= $totalpage+1 )

{

$endpage = $totalpage+1;

}

if($endpage==1)

{

$endpage = 2;

}

for($this->PageNo=$startpage; $this->PageNo < $endpage; $this->PageNo++)

{

$this->ParseDMFields($this->PageNo,1);

$makeFile = $this->GetMakeFileRule($this->Fields['id'],'list',$this->Fields['typedir'],'',$this->Fields['namerule2']);

$makeFile = str_replace("{page}", $this->PageNo, $makeFile);

$murl = $makeFile;

if(!preg_match("/^\//", $makeFile))

{

$makeFile = "/".$makeFile;

}

$makeFile = $this->GetTruePath().$makeFile;

$makeFile = preg_replace("/\/{1,}/", "/", $makeFile);

$makeFile=str_replace($cfg_arcdir.'/',DEDEWAPPATH . '/',$makeFile);

$murl = $this->GetTrueUrl($murl);

if(!is_dir(dirname($makeFile))) {

mkdir(dirname($makeFile), 0777, true);

}

$this->dtp->SaveTo($makeFile);

//如果啟用遠程發布則需要進行判斷

if($cfg_remote_site=='Y'&& $isremote == 1)

{

//分析遠程文件路徑

$remotefile = str_replace(DEDEROOT, '',$makeFile);

$localfile = '..'.$remotefile;

$remotedir = preg_replace('/[^\/]*\.html/', '',$remotefile);

//不相等則說明已經切換目錄則可以創建鏡像

$this->ftp->rmkdir($remotedir);

$this->ftp->upload($localfile, $remotefile, 'acii');

}

}

if($startpage==1)

{

//如果列表啟用封面文件,復制這個文件第一頁

if($this->TypeLink->TypeInfos['isdefault']==1

&& $this->TypeLink->TypeInfos['ispart']==0)

{

$onlyrule = $this->GetMakeFileRule($this->Fields['id'],"list",$this->Fields['typedir'],'',$this->Fields['namerule2']);

$onlyrule = str_replace("{page}","1",$onlyrule);

$list_1 = $this->GetTruePath().$onlyrule;

$list_1=str_replace($cfg_arcdir.'/',DEDEWAPPATH . '/',$list_1);

$murl = MfTypedir($this->Fields['typedir']).'/'.$this->Fields['defaultname'];

//如果啟用遠程發布則需要進行判斷

if($cfg_remote_site=='Y'&& $isremote == 1)

{

//分析遠程文件路徑

$remotefile = $murl;

$localfile = '..'.$remotefile;

$remotedir = preg_replace('/[^\/]*\.html/', '',$remotefile);

//不相等則說明已經切換目錄則可以創建鏡像

$this->ftp->rmkdir($remotedir);

$this->ftp->upload($localfile, $remotefile, 'acii');

}

$indexname = $this->GetTruePath().$murl;

$indexname=str_replace($cfg_arcdir.'/',DEDEWAPPATH . '/',$indexname);

copy($list_1,$indexname);

}

}

}









找到580行函數function MakePartTemplets()

修改最后面的代碼

return $this->GetTrueUrl($makeUrl);修改成

$returl=$this->GetTrueUrl($makeUrl);

$this->MakeWapPartTemplets();

return $returl;







584行添加函數function MakeWapPartTemplets()

代碼如下

function MakeWapPartTemplets()

{

global $cfg_df_style,$cfg_arcdir;

$this->PartView = new PartView($this->TypeID,false);

$this->PartView->SetTypeLink($this->TypeLink);

$nmfa = 0;

$tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir'];

if($this->Fields['ispart']==1)

{

$tempfile = str_replace("{tid}",$this->TypeID,$this->Fields['tempindex']);

$tempfile = str_replace("{cid}",$this->ChannelUnit->ChannelInfos['nid'],$tempfile);

$tempfile = $tmpdir."/".$tempfile;

$tempfile=str_replace('/'.$GLOBALS['cfg_df_style'].'/',DEDEWAPTEMPLATESPATH,$tempfile);

if(!file_exists($tempfile))

{

$tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default.htm";

}

$this->PartView->SetTemplet($tempfile);

}

else if($this->Fields['ispart']==2)

{

//跳轉網址

// return $this->Fields['typedir'];

}

CreateDir(MfTypedir($this->Fields['typedir']));

$makeUrl = $this->GetMakeFileRule($this->Fields['id'],"index",MfTypedir($this->Fields['typedir']),$this->Fields['defaultname'],$this->Fields['namerule2']);

$makeUrl = preg_replace("/\/{1,}/", "/", $makeUrl);

$makeFile = $this->GetTruePath().$makeUrl;

$makeFile=str_replace($cfg_arcdir.'/',DEDEWAPPATH . '/',$makeFile);

if($nmfa==0)

{

if(!is_dir(dirname($makeFile))) {

mkdir(dirname($makeFile), 0777, true);

}

$this->PartView->SaveToHtml($makeFile);

//如果啟用遠程發布則需要進行判斷

if($GLOBALS['cfg_remote_site']=='Y'&& $isremote == 1)

{

//分析遠程文件路徑

$remotefile = str_replace(DEDEROOT, '',$makeFile);

$localfile = '..'.$remotefile;

$remotedir = preg_replace('/[^\/]*\.html/', '',$remotefile);

//不相等則說明已經切換目錄則可以創建鏡像

$this->ftp->rmkdir($remotedir);

$this->ftp->upload($localfile, $remotefile, 'acii');

}

}

else

{

if(!file_exists($makeFile))

{

$this->PartView->SaveToHtml($makeFile);

//如果啟用遠程發布則需要進行判斷

if($cfg_remote_site=='Y'&& $isremote == 1)

{

//分析遠程文件路徑

$remotefile = str_replace(DEDEROOT, '',$makeFile);

$localfile = '..'.$remotefile;

$remotedir = preg_replace('/[^\/]*\.html/', '',$remotefile);

//不相等則說明已經切換目錄則可以創建鏡像

$this->ftp->rmkdir($remotedir);

$this->ftp->upload($localfile, $remotefile, 'acii');

}

}

}

}













首頁生成靜態頁修改代碼

后臺目錄找到:makehtml_homepage.php文件,47行:

$pv->SaveToHtml($homeFile);后面加上代碼:

$pv->SetTemplet(str_replace('/'.$cfg_df_style.'/',DEDEWAPTEMPLATESPATH,$cfg_basedir.$cfg_templets_dir."/".$templet));

$pv->SaveToHtml(str_replace('/index.html',DEDEWAPPATH.'/index.html',$homeFile));




wap模板中文章路徑或欄目路徑替把pc路徑替換成wap路徑。

打開include目錄下extend.func.php在最后面

添加函數

function GetWapUrl($pcurl){

global $cfg_arcdir;

return str_replace($cfg_arcdir.'/',DEDEWAPPATH.'/',$pcurl);

}

模板中欄目url調用

{dede:channelartlist typeid='top' }

<a href="{dede:field.typeurl function='GetWapUrl(@me)'/}">{dede:field.typename/}</a>

{/dede:channelartlist}

文章url調用

<a href="[field:arcurl function='GetWapUrl(@me)' /]">[field:title/]</a>






基本的就是這些,細節根據各自要求修改



收縮
  • 微信客服
  • 微信二維碼
  • 電話咨詢

  • 400-1100-266
主站蜘蛛池模板: 巴中市| 吴旗县| 松原市| 玛曲县| 钦州市| 南靖县| 吉首市| 洞头县| 双牌县| 汉川市| 永川市| 富宁县| 湖南省| 博乐市| 蓝田县| 铜鼓县| 霞浦县| 陇川县| 西峡县| 县级市| 赤城县| 泉州市| 工布江达县| 启东市| 衡水市| 桐庐县| 汝州市| 宝清县| 卫辉市| 黑龙江省| 定远县| 教育| 闵行区| 大港区| 佛冈县| 通化市| 肇庆市| 彩票| 饶阳县| 遂昌县| 新津县|