帝国CMS百度MIP改造newstext正则表达式
本教程主要功能就是把编辑器内的img a标签等替换为MIP标准格式
1、打开/e/class/userfun.php添加处理函数:
function NewsTextReplace($add){ $add['newstext'] = preg_replace('/<img.*?src=(.*?).*?>/is', '<mip-img alt= src=$1></mip-img>', stripslashes($add['newstext'])); $add['newstext'] = preg_replace('/<a.*?href=(.*?).*?</a>/is', '<a data-type=mip data-title=' . $add['title'] . ' href=$1></a>', $add['newstext']); $add['newstext'] = addslashes($add['newstext']); return $add; }
2、打开/e/action/show.php搜索 $GLOBALS[‘navclassid’] = $r[‘classid’];
在前面添加代码:
$r = NewsTextReplace($r);
以上即可!
此函数可以处理所有此信息的字段内容。
更多的需要处理请参考处理函数自行改写。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。