求方法,如何输出导航栏男生、女生的下级分类名称、地址、图片?

qq704401214   ·   发表于 2022-4-7   ·   技术交流

如标题所示

如何遍历导航栏中男生、女生下的分类?

3 条回复   |  直到 2022-4-7 | 233 次浏览

xiaoshuo88
发表于 2022-4-7

可以调用/api/novel/category获取分类结构

结果类似这样

{

            "id": 4,

            "title": "男生",

            "pid": 0,

            "sort": 1,

            "meta_title": "",

            "meta_keywords": "",

            "meta_description": "",

            "icon": "http://site/public/home/images/default_cover.png",

            "template_index": "type.html",

            "template_detail": "novel.html",

            "template_filter": "lists.html",

            "link": "",

            "create_time": 1440469030,

            "update_time": 1539841781,

            "status": 1,

            "type": 0,

            "url": "/lists/4.html",

            "branch": 1,

            "current": 0,

            "subor": [

                {

                    "id": 18,

                    "title": "奇幻玄幻",

                    "pid": 4,

                    "sort": 0,

                    "meta_title": "",

                    "meta_keywords": "",

                    "meta_description": "",

                    "icon": "http://site/public/home/images/default_cover.png",

                    "template_index": "lists.html",

                    "template_detail": "novel.html",

                    "template_filter": "lists.html",

                    "link": "",

                    "create_time": 1536657923,

                    "update_time": 1536657923,

                    "status": 1,

                    "type": 0,

                    "url": "/lists/18.html",

                    "branch": 0,

                    "current": 0

                }...

]

}



评论列表

  • 加载数据中...

编写评论内容

qq704401214
发表于 2022-4-7

xiaoshuo88

2022-4-7

可以调用/api/novel/category获取分类结构

结果类似这样

{

            "id": 4,

            "title": "男生",

            "pid": 0,

            "sort": 1,

            "meta_title": "",

            "meta_keywords": "",

            "meta_description": "",

            "icon": "http://site/public/home/images/default_cover.png",

            "template_index": "type.html",

            "template_detail": "novel.html",

            "template_filter": "lists.html",

            "link": "",

            "create_time": 1440469030,

            "update_time": 1539841781,

            "status": 1,

            "type": 0,

            "url": "/lists/4.html",

            "branch": 1,

            "current": 0,

            "subor": [

                {

                    "id": 18,

                    "title": "奇幻玄幻",

                    "pid": 4,

                    "sort": 0,

                    "meta_title": "",

                    "meta_keywords": "",

                    "meta_description": "",

                    "icon": "http://site/public/home/images/default_cover.png",

                    "template_index": "lists.html",

                    "template_detail": "novel.html",

                    "template_filter": "lists.html",

                    "link": "",

                    "create_time": 1536657923,

                    "update_time": 1536657923,

                    "status": 1,

                    "type": 0,

                    "url": "/lists/18.html",

                    "branch": 0,

                    "current": 0

                }...

]

}



可以用标签循环到出吗?新手不太会这个

评论列表

  • 加载数据中...

编写评论内容

xiaoshuo88
发表于 2022-4-7

qq704401214

2022-4-7

可以用标签循环到出吗?新手不太会这个

xd是准备把这个分类显示在哪?


如果在模板的话在需要显示的控制器方法添加数据绑定

$category =  ;//可以参考/api/novel/category 接口的写法,只获取要的字段
$this->assign('category',$category);

然后就可以在对应view的html里面用volist标签循环了

{volist name="category" id="vo"}
{/volist}


评论列表

  • 加载数据中...

编写评论内容
登录后才可发表内容