PHPCMS v9过滤采集内容中CSS样式的实现方法

在PHPCMS v9采集内容的时候,由于采集规则的原因,可能会无法完全过滤采集目标的CSS样式,这样就会导致文章发布出来后排版错乱。本文教你在后台公共函数库中添加一个函数,过滤掉采集来的CSS样式

方法如下:

  1、找到\phpcms\libs\functions\global.func.php 打开,然后添加函数


复制代码
代码如下:

function htmrp($str) {
$str = preg_replace("/]*>/i", "", $str);
$str = preg_replace("/<\/script>/i", "", $str);
$str = preg_replace("/]*>/i", "", $str);
$str = preg_replace("/<\/iframe>/i", "", $str);
$str = preg_replace("/]*>/i", "", $str);
$str = preg_replace("/<\/style>/i", "", $str);
$str = preg_replace("/]*>/i", "", $str);
$str = preg_replace("/<\/div>/i", "", $str);
return $str;
}

2、修改当前模板中文章内容页模板show.html

  界面—模板风格—详情列表—content—show.html

  找到

{if $allow_visitor==1}
     {$content}

  修改为

复制代码
代码如下:

{if $allow_visitor==1}
{htmrp($content)}

  3、更新缓存,刷新即可。

以上就是PHPCMS v9过滤采集内容中CSS样式的实现方法的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » CMS教程