联系官方销售客服

1835022288

028-61286886

应用插件 版主:官方插件技术组
栏目图片回调求解将栏目图片转换出来!
类型:迅睿CMS 更新时间:2020-09-17 23:22:31 栏目

栏目图片回调求解,将栏目图片转换出来

"hits": "55",
            "name": {
                "id": "4",
                "pid": "1",
                "pids": "0,1",
                "name": "女生头像",
                "dirname": "nstx",
                "pdirname": "touxiang/",
                "child": 0,
                "childids": 4,
                "thumb": "2745",
                "show": "1",
                "setting": {
                    "linkurl": "",
                    "seo": {
                        "l
                    },
 public function ppp_list_data($data) {
    
        $rt = [];
        // 这里根据项目的$data输出格式来定义PHP的数据写法,
        // 每个接口的写法几乎不一样,下面是测试例子
        if ($data['list']) {
            foreach ($data['list'] as $t) {
                $img = [];
                foreach ($t['images'] as $i) {
                    $img[] = dr_get_file($i['file']);
                }
    $keywordsArr = [];
    if($t['keywords']!='')
    {
     $keywordsArr = explode(',',rtrim($t['keywords'],','));
    }
                $rt[] = [
                    'title' => $t['title'],
                    'id' => $t['id'],
     'keywords'=>$keywordsArr,
     'comments'=>$t['comments'],
     'author'=>$t['author'],
     'avatar'=>dr_avatar($t['uid']),
     'hits'=>$t['hits'],
     'name' => dr_cat_value($t['catid']),
     'uid'=>$t['uid'],
     'catid'=>$t['catid'],
     'comments'=>$t['comments'],
     'favorites'=>$t['favorites'],
     'support'=>$t['support'],
                    'thumb' => dr_thumb($t['thumb'], 200, 200),
                    'updatetime' => dr_fdate($t['_updatetime']),
                    'images' => $img,
                ];
            }
        }
        
        return $rt;
    }


回帖
  • 易学习
    #1楼    易学习
    2020-09-17 22:59:53
    Chrome 0
    看不到隐藏内容,帮不了你了
  • 华仔
    #2楼    华仔
    2020-09-17 23:02:24
    Chrome 0
    public function ppp_list_data($data) {
        
            $rt = [];
            // 这里根据项目的$data输出格式来定义PHP的数据写法,
            // 每个接口的写法几乎不一样,下面是测试例子
            if ($data['list']) {
                foreach ($data['list'] as $t) {
                    $img = [];
                    foreach ($t['images'] as $i) {
                        $img[] = dr_get_file($i['file']);
                    }
        $keywordsArr = [];
        if($t['keywords']!='')
        {
         $keywordsArr = explode(',',rtrim($t['keywords'],','));
        }
                    $rt[] = [
                        'title' => $t['title'],
                        'id' => $t['id'],
         'keywords'=>$keywordsArr,
         'comments'=>$t['comments'],
         'author'=>$t['author'],
         'avatar'=>dr_avatar($t['uid']),
         'hits'=>$t['hits'],
         'name' => dr_cat_value($t['catid']),
         'uid'=>$t['uid'],
         'catid'=>$t['catid'],
         'comments'=>$t['comments'],
         'favorites'=>$t['favorites'],
         'support'=>$t['support'],
                        'thumb' => dr_thumb($t['thumb'], 200, 200),
                        'updatetime' => dr_fdate($t['_updatetime']),
                        'images' => $img,
                    ];
                }
            }
            
            return $rt;
        }
    易学习
  • 易学习
    #3楼    易学习
    2020-09-17 23:08:33
    Chrome 0
    public function ppp_list_data($data) {
    print_r($data);
    }
    这样写输出什么内容呢
  • 华仔
    #4楼    华仔
    2020-09-17 23:15:43
    Chrome 0
    易学习 这是我接口返回的数据,"thumb": "2745",就是要转换的栏目地址。是这个参数里面的'name' => dr_cat_value($t['catid']),
    "data": [
            {
                "title": "小葵好可爱哦!",
                "id": "604",
                "keywords": [
                    "可爱"
                ],
                "comments": "0",
                "author": "梦",
                
                "hits": "5",
                "name": {
                    "id": "9",
                    "pid": "2",
                    "pids": "0,2",
                    "name": "动漫壁纸",
                    "dirname": "dongmanbizhi",
                    "pdirname": "bizhi/",
                    "child": 0,
                    "childids": 9,
                    "thumb": "2745",
                    "show": "1",
                    "setting": {
                        "linkurl": "",
                        "seo": {
                            
                        },
                        "template": {
                            "pagesize": "10",
                            "mpagesize": "10",
                            "list": "list.html",
                            "category": "category.html",
                            "search": "search.html",
                            "show": "show.html"
                        },
                        "cat_field": null,
                        "html": 0,
                        "urlrule": 3
                    },
                    "displayorder": "0",
                    "mid": "p",
                    "topid": "2",
                    "domain": "",
                    "mobile_domain": "",
                    "catids": [
                        "9"
                    ],
                    "tid": 1,
                    "permission": [
                        
                    ],
                    "url": "/p/dongmanbizhi.html",
                    "total": 73,
                    "field": [
                        
                    ]
                },
                "uid": "1",
                "catid": "9",
                "favorites": "0",
                "support": "0",
                "thumb": "/static/assets/images/nopic.gif",
                "updatetime": "3天前",
                "images": [
                    
                ]
            },
  • 九戒
    #5楼    九戒
    2020-09-17 23:20:01
    Chrome 1
    public function ppp_list_data($data) {
        
            $rt = [];
            // 这里根据项目的$data输出格式来定义PHP的数据写法,
            // 每个接口的写法几乎不一样,下面是测试例子
            if ($data['list']) {
                foreach ($data['list'] as $t) {
                    $img = [];
                    foreach ($t['images'] as $i) {
                        $img[] = dr_get_file($i['file']);
                    }
        $keywordsArr = [];
        if($t['keywords']!='')
        {
         $keywordsArr = explode(',',rtrim($t['keywords'],','));
        }
        $cat = dr_cat_value($t['catid']);
        $cat['thumb'] = dr_get_file($cat['thumb']);
                    $rt[] = [
                        'title' => $t['title'],
                        'id' => $t['id'],
         'keywords'=>$keywordsArr,
         'comments'=>$t['comments'],
         'author'=>$t['author'],
         'avatar'=>dr_avatar($t['uid']),
         'hits'=>$t['hits'],
         'name' =>  $cat,
         'uid'=>$t['uid'],
         'catid'=>$t['catid'],
         'comments'=>$t['comments'],
         'favorites'=>$t['favorites'],
         'support'=>$t['support'],
                        'thumb' => dr_thumb($t['thumb'], 200, 200),
                        'updatetime' => dr_fdate($t['_updatetime']),
                        'images' => $img,
                    ];
                }
            }
            
            return $rt;
        }
    这是php基础语法了
    满意答案
  • 华仔
    #6楼    华仔
    2020-09-17 23:22:31
    Chrome 0
    @九戒:正确,非常感谢!