ThinkPHP3.2 volist嵌套循环显示原理

时间:2023-03-08 16:12:05
ThinkPHP3.2 volist嵌套循环显示原理
php页面:
$fatherList = $Document->where('pid=1')->select();
        foreach($fatherList as $n=> $val)
        {
            $fatherList[$n]['childList']=D('Document')->where('category_id=\''.$val['id'].'\'')->select();
                //$Baojia->where('belongto=\''.$val['name'].'\'')->select();
        }
        $this->assign('fatherList',$fatherList);

html页面:
<volist name="fatherList" id='data'>
       <dl>
                 <dt class="active">{$data.title}</dt>
                 <dd style="display:block;">
                      <volist name="data['childList']" id="vo">
                            <a class="active" title="简介" href="http://youlanzihun.blog.163.com/">·{$vo.title}</a>
                     </volist>
                </dd>
      </dl>

</volist>

 转自:http://youlanzihun.blog.163.com/blog/static/3731171020142214112126/