<div class="layui-form">
<div class="layui-collapse" lay-accordion id="chapterlistbox">
<?php foreach($chapters as $chapterkey => $onechapter){ ?>
  <div class="layui-colla-item">
    <h2 class="layui-colla-title"><span><?php echo $onechapter->name; ?></span></h2>
    <div class="layui-colla-content<?php if(stripos($treepath, ','. $onechapter->id .',')!==false || empty($treepath)){echo ' layui-show';} ?>">
      <div class="layui-collapse" lay-accordion id="sectionlistbox_<?php echo $onechapter->id; ?>">
        <?php foreach($onechapter->children as $sectionkey => $onesection){ ?>
        <div class="layui-colla-item">
          <h2 class="layui-colla-title"><span><?php echo $onesection->name; ?></span></h2>
          <div class="layui-colla-content<?php if(stripos($treepath, ','. $onesection->id .',')!==false || empty($treepath)){echo ' layui-show';} ?>">
            <div class="layui-collapse" lay-accordion id="knowledlistbox_<?php echo $onesection->id; ?>">
              <?php foreach($onesection->children as $knowledkey => $oneknowled){ ?>
              <div class="layui-colla-item">
                <h2 class="layui-colla-title"><span><?php echo $oneknowled->name; ?></span></h2>
              </div>
              <?php } ?>
            </div>
          </div>
        </div>
        <?php } ?>
      </div>
    </div>
  </div>
<?php } ?>
</div>
</div>