国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > 織夢DEDE > 正文

織夢CMS改造mip教程

2024-07-12 08:27:37
字體:
供稿:網(wǎng)友

頁面整體結(jié)構(gòu)改造

<!DOCTYPE html><html mip>    <head>        <meta charset="UTF-8">        <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"><link rel="stylesheet" type="text/css" href="/d/file/202012/3frl03uqsdt440.html" ></mip-img><script src="/d/file/202012/h55ugozn0qx441.html"></mip-img>

我增加了一個函數(shù),在include 里面的extend.func.php 下。這個應(yīng)該所有的php后臺都是試用的

 

function replaceurl($content){//$pattern = "/<img(.*?)src=('|")([^>]*).(bmp|gif|jpeg|jpg|png)('|")(.*?)>/i";$pattern="/<img.*?src=['|"](.*?(?:[.gif|.jpg|.jpeg]|.png]|.bmp]))['|"].*?[/]?>/";preg_match_all($pattern, $content,$matches);$full_img = $matches[0];$full_src = $matches[1];foreach ($full_img as $k => $v) {$v1 = str_replace("<img", "<mip-img", $v);$v1 = str_replace("/>", "></mip-img>", $v1);$v1 = str_replace('src="/ueditor','src="/ueditor',$v1);$new_path = $url.$full_src[$k];$v1 = str_replace($full_src[$k], $new_path, $v1);$content = str_replace($v, $v1, $content);}return $content;}

后面又研究了下,如果是用的織夢的編輯器,就會產(chǎn)生style,于是我又弄了另外一個然后織夢調(diào)用主體內(nèi)容 {dede:field.body function='replaceurl(@me)'/} 執(zhí)行了下函數(shù)替換了img標簽。

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

這個的話就直接把style去掉了,好歹解決了吧!推薦用下面這個。

style標簽去除

我們在里面會更改字的樣子,就會產(chǎn)生style,又得替換

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

還是一樣主體內(nèi)容 {dede:field.body function='replaceurl(@me)'/}  這樣調(diào)用,具體如果還需要詳細的話可以更改里面的正則表達式

不去掉文章style

比較麻煩,網(wǎng)上看見的,沒測試是否可行,可以自行研究下,大概就是提取body里面的style生成class然后再調(diào)用到頭部去

因為我的并沒有用多少style所以懶搞的了。

(1)、找到include/arc.archives.class.php,找到函數(shù)ReplaceKeyword($kw,&$body),大概1182行,在這個函數(shù)后面添加如下2個函數(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;}

$this->SplitTitles = Array();上面,(2)在函數(shù)ParAddTable()里的

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標簽內(nèi)添加如下代碼:<style mip-custom>{dede:field.custom_style/}</style>
 

文章內(nèi)鏈更換

注明:內(nèi)鏈請勿填寫絕對地址,還是在上面2、3的方法里面改,還是增加一個變量正則,然后替換。www.lol9.cn

 
function replaceurl($content){$pattern = Array("/<img(.*?)src=('|")([^>]*).(bmp|gif|jpeg|jpg|png)('|")(.*?)>/i","/style=(.*?)>/i",'/<ab[^>]+bhref="([^"]*)"[^>]*>/i');$replacement = Array("<mip-img  popup  src=/$3.$4></mip-img>",">",'<a  data-type="mip" href=http://mip.lol9.cn$1>');$content = preg_replace($pattern, $replacement, $content);return $content;}
 

文章文檔關(guān)鍵詞鏈接更換

如果你用了織夢自帶的關(guān)鍵字加鏈接,在核心》批量維護》文檔關(guān)鍵詞維護里面,那么就要替換成絕對地址與增加mip鏈接格式

打開include/arc.archives.class.php 文件 ,大概在1219行,在變量$key_url前面加上自己的鏈接,與href前面加上 data-type=mip

1  
$query = "SELECT * FROM dede_keywords WHERE rpurl<>'' ORDER BY rank DESC";$this->dsql->SetQuery($query);$this->dsql->Execute();while($row = $this->dsql->GetArray()){$key = trim($row['keyword']);$key_url=trim($row['rpurl']);$karr[] = $key;$kaarr[] = "<a  data-type=mip href='http://mip.lol9.cn$key_url'><u>$key</u></a>";}
 

 

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 仲巴县| 堆龙德庆县| 彭阳县| 专栏| 德惠市| 许昌市| 崇文区| 日土县| 张家口市| 咸宁市| 凤山市| 汽车| 闻喜县| 阿拉善左旗| 昌平区| 东光县| 张掖市| 南溪县| 仙游县| 库车县| 孝感市| 泾川县| 高陵县| 通道| 乐亭县| 玉山县| 什邡市| 青川县| 平度市| 连云港市| 项城市| 泰宁县| 永靖县| 个旧市| 三亚市| 呼图壁县| 天台县| 浠水县| 利津县| 商都县| 泗洪县|