联系官方销售客服

1835022288

028-61286886

应用插件 版主:官方插件技术组
4级导航接口如何实现,接口撰写 栏目接口
类型:迅睿CMS 更新时间:2024-02-20 16:27:14 自定义模板代码 栏目数据 API接口
插件 API接口 V7.7
应用作者 迅睿官方团队
发布时间 2019-03-14 09:57:26
更新时间 2024-08-24 20:57:34

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

170841454197b262.txt

imageimage

插件教程:https://www.xunruicms.com/doc/app-361.html

回帖
  • 优速开发工作室
    #1楼    优速开发工作室
    2024-02-20 16:18:09
    Chrome 1
    这个代码有点多了,你数组思维错误了
    {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
    Chrome 0
    层级没有组装对吧,被覆盖了
  • GoWorkRoom
    #3楼    GoWorkRoom
    2024-02-20 16:26:11
    Chrome 0
    php技术不过关啊,楼层覆盖了,变得无效了
  • DkjbY
    #4楼    DkjbY
    2024-02-20 16:27:14
    Chrome 0
    @优速开发工作室:感谢帮助