在phpCMS v9采集内容的时候,由于采集规则的原因,可能会无法完全过滤采集目标的CSS样式,这样就会导致文章发布出来后排版错乱。本文教你在后台公共函数库中添加一个函数,过滤掉采集来的CSS样式,方法如下:
1、找到phpcmslibsfunctionsglobal.func.php 打开,然后添加函数
functionhtmrp($str){$str=PReg_replace("/<script[^>]*>/i","",$str);$str=preg_replace("/</script>/i","",$str);$str=preg_replace("/<iframe[^>]*>/i","",$str);$str=preg_replace("/</iframe>/i","",$str);$str=preg_replace("/<style[^>]*>/i","",$str);$str=preg_replace("/</style>/i","",$str);$str=preg_replace("/<div[^>]*>/i","",$str);$str=preg_replace("/</div>/i","",$str);return$str;}
2、修改当前模板中文章内容页模板show.html
界面—模板风格—详情列表—content—show.html
找到
{if $allow_visitor==1}
{$content}
修改为
{htmrp($content)}
3、更新缓存,刷新即可。