织梦CMS改造mip教程

2022-10-29 16:27编辑: www.jxszl.com景先生毕设
页面整体结构改造






 更多精彩就在: 51免费论文网|www.jxszl.com 
le=I.,initial-scale=I.">



样式








mip规范结构大致如上代码,具体的就自行修改.

mip图片改造
图片的格式需要换成

我增加了I.个函数,在include里面的extend.func.php下.这个应该所有的php后台都是试用的

functionreplaceurl($content){
//$pattern="/*).(bmp|gif|jpeg|jpg|png)(|")(.*?)>/i";
$pattern="//";
preg_match_all($pattern,$content,$matches);
$full_img=$matches[0;
$full_src=$matches[I.;
foreach($full_imgas$k=>$v){
$vI.=str_replace("$vI.=str_replace("/>",">",$vI.);
$vI.=str_replace(src="/ueditor,src="/ueditor,$vI.);
$new_path=$url.$full_src[$k;
$vI.=str_replace($full_src[$k,$new_path,$vI.);
$content=str_replace($v,$vI.,$content);
}
return$content;
}

后面又研究了下,如果是用的织梦的编辑器,就会产生style,于是我又弄了另外I.个然后织梦调用主体内容{dede:field.bodyfunction=replaceurl(@me)/}执行了下函数替换了img标签.

functionreplaceurl($content){
$pattern=Array("/*).(bmp|gif|jpeg|jpg|png)(|")(.*?)>/i","/style=(.*?)>/i");
$replacement=Array("",">");
$content=preg_replace($pattern,$replacement,$content);
return$content;
}

这个的话就直接把style去掉了,好歹解决了吧!推荐用下面这个.

style标签去除
我们在里面会更改字的样子,就会产生style,又得替换

functionreplaceurl($content){
$pattern=Array("/*).(bmp|gif|jpeg|jpg|png)(|")(.*?)>/i","/style=(.*?)>/i");
$replacement=Array("",">");
$content=preg_replace($pattern,$replacement,$content);
return$content;
}

还是I.样主体内容{dede:field.bodyfunction=replaceurl(@me)/}这样调用,具体如果还需要详细的话可以更改里面的正则表达式

不去掉文章style
比较麻烦,网上看见的,没测试是否可行,可以自行研究下,大概就是提取body里面的style生成class然后再调用到头部去

因为我的并没有用多少style所以懒搞的了.

(I.).找到include/arc.archives.class.php,找到函数ReplaceKeyword($kw,&$body),大概I.I.VIIIII行,在这个函数后面添加如下II个函数:

functionreplacePicUrl($content=null,$url=""){
$pattern="/*).(bmp|gif|jpeg|jpg|png)(|")(.*?)>/i";
$replacement="";
$content=preg_replace($pattern,$replacement,$content);
return$content;
}
functiongetStyle($content=null){
preg_match_all("/style=(|")([^"+)(|")/",
$content,$matches);
$styles=$matches[0;
$styles_value=$matches[II;
$style_custom="";
$i=0;
foreach($styles_valueas$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();上面,(II)在函数ParAddTable()里的

unset($row);下面,大概IIVIII行添加如下代码:

$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;

(III).找到函数MakeHtml($isremote=0),大概IIIVVIII行,在里面的

$this->Fields[filename=empty($this->Fields[filename)?:$this->Fields[filename;下面添加如下代码:

$this->Fields[style_custom=empty($this->Fields[style_custom)?:$this->Fields[style_custom;
(IV).在templete的article_article.htm模板中的head标签内添加如下代码:

{dede:field.custom_style/}


文章内链更换
注明:内链请勿填写绝对地址,还是在上面II.III的方法里面改,还是增加I.个变量正则,然后替换.www.adminbuy.cn

functionreplaceurl($content){
$pattern=Array("/*).(bmp|gif|jpeg|jpg|png)(|")(.*?)>/i","/style=(.*?)>/i",/+bhref="([^"*)"[^>*>/i);
$replacement=Array("",">",);
$content=preg_replace($pattern,$replacement,$content);
return$content;
}

文章文档关键字链接更换
如果你用了织梦自带的关键字加链接,在核心批量维护文档关键字维护里面,那么就要替换成绝对地址与增加mip链接格式

打开include/arc.archives.class.php文件,大概在I.III.IX行,在变量$key_url前面加上自己的链接,与href前面加上data-type=mip

$query="SELECT*FROMdede_keywordsWHERErpurl<>ORDERBYrankDESC";
$this->dsql->SetQuery($query);
$this->dsql->Execute();
while($row=$this->dsql->GetArray())
{
$key=trim($row[keyword]);
$key_url=trim($row[rpurl]);
$karr[]=$key;
$kaarr[]="$key";
}


原文链接:http://www.jxszl.com/biancheng/dedecms/74899.html