帝国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);
此函数可以处理所有此信息的字段内容。
更多的需要处理请参考处理函数自行改写。


上一篇:帝国CMS根据栏目ID获取栏目字段信息

下一篇:帝国CMS模板中内容关键字加粗显示,加背景颜色等的方法!


newstext 正则表达
Copyright © 2002-2019 测速网 https://www.inhv.cn/ 皖ICP备2023010105号 城市 地区 街道
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!
热门搜索