日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

织梦mip改造

發(fā)布時(shí)間:2023/12/20 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 织梦mip改造 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

前2天接了個(gè)織夢(mèng)改造mip,之前沒怎么接觸過(guò)織夢(mèng),mip也沒怎么接觸過(guò),這里記錄下改造過(guò)程,其實(shí)需要改造的地方不多。

首先頁(yè)面改造:

按照mip標(biāo)準(zhǔn):

? ? ? ?1、需要給html標(biāo)簽加上mip,即:<html mip>

? ? ? ?2、字符集統(tǒng)一為utf-8

? ? ? ?3、需要meta:?<meta name="viewport" content="width=device-width,initial-scale=1">

? ? ? ?4、引入mip樣式支持和javascript支持:<link rel="stylesheet" type="text/css" href="https://mipcache.bdstatic.com/static/v1/mip.css" >

<script src="https://mipcache.bdstatic.com/static/v1/mip.js" ></script >

? ? ? ?5、head標(biāo)簽中引入 <link rel="canonical" href="http(s)://xxx" > xxx代表原來(lái)的網(wǎng)站,如果只有手機(jī)端頁(yè)面,那么這個(gè)href就是當(dāng)前頁(yè)面就可以了,如果還有電腦端的頁(yè)面,那這個(gè)href可以指向電腦端的頁(yè)面

? ? ? ?6、其他的就按照mip標(biāo)準(zhǔn)套, 其實(shí)大部分還是修改img標(biāo)簽為mip-img,a標(biāo)簽可以不用修改, 還是樣式不能直接用style=寫在標(biāo)簽上了,如果實(shí)在需要在當(dāng)前頁(yè)寫css,需要在頭部添加<style mip-custom></style>


程序改造:

程序需要改造的地方有2個(gè):

1、分頁(yè): 找到include/arc.listview.class.php里的GetPageListDM($list_len,$listitem="index,end,pre,next,pageno"),大概在981行,在這個(gè)函數(shù)里面添加:

$typeDir = str_replace('{cmspath}', '', $this->Fields['typedir']);

然后在有href=的地方添加:.$GLOBALS['cfg_basehost']."/".$typeDir."/"

完整鏈接如:

if($this->PageNo != 1)
? ? ? ? {
? ? ? ? ? ? $prepage.="<li><a href='".$GLOBALS['cfg_basehost']."/".$typeDir."/".str_replace("{page}",$prepagenum,$tnamerule)."'>上一頁(yè)</a></li>\r\n";
? ? ? ? ? ? $indexpage="<li><a href='".$GLOBALS['cfg_basehost']."/".$typeDir."/".str_replace("{page}",1,$tnamerule)."'>首頁(yè)</a></li>\r\n";
? ? ? ? }

if($this->PageNo!=$totalpage && $totalpage>1)
? ? ? ? {
? ? ? ? ? ? $nextpage.="<li><a href='".$GLOBALS['cfg_basehost']."/".$typeDir."/".str_replace("{page}",$nextpagenum,$tnamerule)."'>下一頁(yè)</a></li>\r\n";
? ? ? ? ? ? $endpage="<li><a href='".$GLOBALS['cfg_basehost']."/".$typeDir."/".str_replace("{page}",$totalpage,$tnamerule)."'>末頁(yè)</a></li>\r\n";
? ? ? ? }

到此,分頁(yè)改造完畢。

2、內(nèi)容改造比較復(fù)雜:

(1)、找到include/arc.archives.class.php,找到函數(shù)ReplaceKeyword($kw,&$body),大概1182行,在這個(gè)函數(shù)后面添加如下2個(gè)函數(shù):

function replacePicUrl($content = null, $url="") {
? ? ? ? $pattern = "/<img(.*?)src=('|\")([^>]*).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i";
? ? ? ? $replacement = "<mip-img src={$url}$3.$4></mip-img>";
? ? ? ? $content = preg_replace($pattern, $replacement, $content);
? ? ? ? return $content;
? ? }


? ? function getStyle($content = null){
? ? ? ? ? preg_match_all("/style=('|\")([^'\"]+)('|\")/",
? ? ? ? ? ? ? ? $content,$matches);
? ? ? ? ? $styles = $matches[0];
? ? ? ? ? $styles_value = $matches[2];
? ? ? ? ? $style_custom = "";
? ? ? ? ? $i = 0;
? ? ? ? ? foreach($styles_value as $key){
? ? ? ? ? ? $style_custom .= ".class".$i."{".$key."}";
? ? ? ? ? ? $class_name = 'class="class'.$i.'"';
? ? ? ? ? ?
? ? ? ? ? ? $replacements = $class_name;
? ? ? ? ? ??
? ? ? ? ? ? $patterns = $styles[$i];
? ? ? ? ? ? $content = str_replace($patterns, $replacements, $content);
? ? ? ? ? ? $i++;
? ? ? ? }
? ? ? ? $res['style_custom'] = $style_custom;
? ? ? ? $res['content'] = $content;
? ? ? ? return $res;
? ? }

(2)、在函數(shù)ParAddTable()里的$this->SplitTitles = Array();上面,unset($row);下面,大概253行添加如下代碼:

$content = $this->replacePicUrl($this->Fields['body'], $GLOBALS['cfg_basehost']);
? ? ? ? $content_arr = $this->getStyle($content);?
? ? ? ? $this->Fields['body'] = $content_arr['content'];
? ? ? ? $this->Fields['style_custom'] = $content_arr['style_custom'];

(3)、找到函數(shù)MakeHtml($isremote=0),大概358行,在里面的$this->Fields['filename'] = empty($this->Fields['filename'])? '' : $this->Fields['filename'];下面添加如下代碼:$this->Fields['style_custom'] = empty($this->Fields['style_custom'])? '' : $this->Fields['style_custom'];?

? ? ? ? (4)、在templete的article_article.htm模板中的head標(biāo)簽內(nèi)添加如下代碼:

<style mip-custom>
? {dede:field.custom_style/}
? </style>

(5)、最后一步,到后臺(tái):核心-頻道模型-內(nèi)容模型管理列表找到普通文章,并點(diǎn)擊編輯,進(jìn)入字段管理并添加字段custom_style,表示從內(nèi)容編輯器中提取出來(lái)的樣式,選多行文本。


到此,織夢(mèng)簡(jiǎn)單改造mip已完成,但是mip對(duì)js有限制,目前還沒有比較完善的文檔,對(duì)于評(píng)論那塊以后研究下mip的js再想辦法。最后記住,a標(biāo)簽的href和mip-img的src都需要完整地址,包括域名。

總結(jié)

以上是生活随笔為你收集整理的织梦mip改造的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。