zblog
当前位置:首页 > 商学院 > zblog > 正文内容

zblog

删除文章内的url链接

豫唐网络2023-11-02 19:55793

    清除url链接可以在入库的时候操作,也可以在前台或者api显示的时候操作。具体怎么显示根据具体情况来选择。

入库操作

文章提交的时候删除文章内的url链接。

1、使用Filter_Plugin_PostArticle_Core接口

Add_Filter_Plugin('Filter_Plugin_PostArticle_Core','ytecn_postarticle_core');

2、添加函数

function ytecn_postarticle_core(&$article) {
$article->Content = preg_replace("/<a[^>]*>(.*?)<\/a>/is", "$1", $article->Content);
}

前台显示操作

如不想文章提交的时候操作,也可以在前台显示的时候,屏蔽掉a标签,但数据库里的数据保持不变。

1、使用Filter_Plugin_ViewPost_Template接口

Add_Filter_Plugin('Filter_Plugin_ViewPost_Template','ytecn_ViewPost_Template');

2、添加函数

function ytecn_ViewPost_Template(&$template){
    global $zbp;
    $article = $template->GetTags('article');
    $article->Content = preg_replace("/<a[^>]*>(.*?)<\/a>/is", "$1", $article->Content);
    $template->SetTags('article', $article);
}

api显示操作

1、使用Filter_Plugin_API_Get_Object_Array接口

Add_Filter_Plugin('Filter_Plugin_API_Get_Object_Array', 'tc_nourl_API_Get_Object_Array');

2、添加函数

function tc_nourl_API_Get_Object_Array(&$object, &$array)
{
    global $zbp, $mod, $act;
    switch (get_class($object)) {
        case 'Post':
            if ($act != "list") {
                $array['Content'] = preg_replace("/<a[^>]*>(.*?)<\/a>/is", "$1", $object->Content);
            }else{
                unset($array['Content']);
            }
            break;
        default:
            break;
    }
}


扫描二维码推送至手机访问。

版权声明:本文由汤阴县豫唐网络科技有限公司发布,如需转载请注明出处。

本文链接:https://www.ytecn.com/post/422.html

分享给朋友:

相关文章

zblogphp打开调试模式的方法zblogphp程序报错怎么办

zblogphp打开调试模式的方法zblogphp程序报错怎么办

        因为出问题了,所以要开调试定位和解决,而不是因为开了调试,所以出问题了。未开调试模式的报错界面  &nb...

zba文件怎么使用?zba文件是什么?

zba文件怎么使用?zba文件是什么?

        .zba是zblogphp的专用应用格式。应用格式又分主题和插件两种。   ...

zblogphp数据字典zblogphp数据库字典zblogphp数据表字段大全

zblogphp数据字典zblogphp数据库字典zblogphp数据表字段大全

        zblogphp系统默认为8张表,分别为category(分类表)、comment(评论表)、config(系统和应用配置表...

zblog提示授权文件非法怎么办

zblog提示授权文件非法怎么办

        zblog在开启主题或者插件的时候,有时候会提示授权文件非法。这种需要怎么处理么?  ...

zblog授权中心zblog商业授权价格

zblog授权中心zblog商业授权价格

        zblog的商用链接,已与2022年01月28从官网移除,git开源协议MIT。如你依然不放心,可以找豫...

zblog插件怎么安装

zblog插件怎么安装

        zblog的插件分为应用中心插件和自定义插件两大类。应用中心插件又分为免费插件和付费插件。自定义插件分为...