求助 版主:官方研发技术组
custom.php 如何正确使用引入的第三方类呢
类型:迅睿CMS 更新时间:2022-07-03 11:58:24 第三方类

发现一个第三方类 Hashids(https://github.com/vinkla/hashids)

很不错的,加密自增ID,想把它应用到自己的内容id 加密,该如何引入呢?我是参考官方教程,但是失败 https://www.xunruicms.com/doc/901.html


一、把项目文件拷贝到 ThirdParty 目录。

image

二、在外面再写一个IntCode.php 引入这个类


image


三、在config/custom.php 增加一个函数

function xxxurl($data) {

    $eid =  \Phpcmf\ThirdParty\IntCode::encode($data['id']);

    return "/".$eid.".html"; // 返回我自己的url规则

}

把这个函数写到ReWrite 内容页规则里面,但是更新内容Url出错了。

image


我引入第三方类的方式有问题么?或者那位指点一下我该如何引入?


回帖
  • #1楼    迅睿框架创始人
    2022-07-03 10:03:00
    Google Pixel 手机 0

    image
    这里需要require 第三方文件
    满意答案
  • cycoo
    #2楼    cycoo
    2022-07-03 11:58:24
    Chrome 0
    迅睿框架创始人:回复~!生成自定义url不出错了。