4级导航接口如何实现,接口撰写 栏目接口

迅睿框架 更新 2024-02-20 16:27:14 DkjbY

"api接口数据"中,用自定义模板代码如附件(用于实现四级导航栏目数据展示),但是不正确,能帮忙看下哪里写错了吗?

170841454197b262.txt

imageimage

方案

  • 优速开发工作室 #1 · 2024-02-20 16:18:09
    满意答案
    这个代码有点多了,你数组思维错误了
    {category module=share pid=0}
    
        {php $api[$key]=[];}
        {php $api[$key]['id']=$t['id'];}
        {php $api[$key]['name']=$t['name'];}
        {php $api[$key]['url']=$t['url'];}
        {php $api[$key]['next']=[];}
    
        {if $t.child}
    
           {category module=share pid=$t.id return=t2}
    
              {php $api[$key]['next'][$key_t2]=[];}
              {php $api[$key]['next'][$key_t2]['id']=$t2['id'];}
              {php $api[$key]['next'][$key_t2]['name']=$t2['name'];}
              {php $api[$key]['next'][$key_t2]['url']=$t2['url'];}
              {php $api[$key]['next'][$key_t2]['next']=[];}
    
              {if $t2.child}
              
                 {category module=share pid=$t2.id return=t3}
                    {php $api[$key]['next'][$key_t2]['next'][$key_t3]=[];}
                    {php $api[$key]['next'][$key_t2]['next'][$key_t3]['id']=$t3['id'];}
                    {php $api[$key]['next'][$key_t2]['next'][$key_t3]['name']=$t3['name'];}
                    {php $api[$key]['next'][$key_t2]['next'][$key_t3]['url']=$t3['url'];}
                    {php $api[$key]['next'][$key_t2]['next'][$key_t3]['next']=[];}
                    
                    {if $t3.child}
                       {category module=share pid=$t3.id return=t4}
                          {php $api[$key]['next'][$key_t2]['next'][$key_t3]['next'][$key_t4]=[];}
                          {php $api[$key]['next'][$key_t2]['next'][$key_t3]['next'][$key_t4]['id']=$t4['id'];}
                          {php $api[$key]['next'][$key_t2]['next'][$key_t3]['next'][$key_t4]['name']=$t4['name'];}
                          {php $api[$key]['next'][$key_t2]['next'][$key_t3]['next'][$key_t4]['url']=$t4['url'];}
                       {/category}
                    {/if}
                    
                    
                 {/category}
              
              {/if}
        
           {/category}
    
        {/if}
    
    {/category}
  • 小鱼儿 #2 · 2024-02-20 16:23:43
    层级没有组装对吧,被覆盖了
  • GoWorkRoom #3 · 2024-02-20 16:26:11
    php技术不过关啊,楼层覆盖了,变得无效了
  • DkjbY #4 · 2024-02-20 16:27:14
    @优速开发工作室:感谢帮助

迅睿系统漏洞

站群分站系统
站群分站系统(2026-10-15)
子站域名新增llms.txt访问
GEO系统
GEO系统(2026-10-14)
修复下载zip空白地址问题 修复流量复刻和任务队列错误
GeoSeo收录宝
GeoSeo收录宝(2026-10-14)
新增 站长工具箱 前端首页自动调用meta 数据
滑块验证码 Gocaptcha
滑块验证码 Gocaptcha(2026-10-13)
基于开源项目 go-captcha 的行为验证码插件,滑动拼图、区域...
GeoSeo工具箱
GeoSeo工具箱(2026-10-13)
优化巡检任务
GeoSeo排名助手
GeoSeo排名助手(2026-10-11)
加入大模型自定义
SEO聚合关键字
SEO聚合关键字(2026-10-11)
优化关键字列表页最多支持1万篇文章,过多会导致服务器扛不住;
CMS内容同步复制
CMS内容同步复制(2026-10-10)
增加时间是否更新的开关