MapController.php 1.5 KB
<?php
namespace app\portal\controller;

use cmf\controller\HomeBaseController;
use app\portal\model\PortalCategoryModel;
use think\Db;

class MapController extends HomeBaseController{

  public function _initialize(){

    parent::_initialize();
    $data = Db::name('slide_item') -> where('slide_id',3) -> find();
    $this -> assign('logo',$data);

    $shuju = Db::name('nav_menu') -> select();
    $data2 = $this -> daohang($shuju);

    $this -> assign('data2',$data2);

  }

  public function daohang($data,$pid=0){

    $arr = [];
    foreach ($data as $key => $value) {
       if($value['parent_id'] == $pid){
          $value['son'] = $this -> daohang($data,$value['id']);
          $arr[] = $value;

       }
    }
    return $arr;


  }





  //显示网站地图
  public function index(){

    //产品中心
    $cptitle = Db::name('nav_menu') -> where('id',18) -> find();
    $cpson = Db::name('nav_menu') -> where('parent_id',18) -> select();
    $this -> assign('cptitle',$cptitle);
    $this -> assign('cpson',$cpson);

    //公司介绍
    $gstitle = Db::name('nav_menu') -> where('id',19) -> find();
    $gsson = Db::name('nav_menu') -> where('parent_id',19) -> select();
    $this -> assign('gstitle',$gstitle);
    $this -> assign('gsson',$gsson);

    //其他
    $qita = Db::name('slide') -> where('id',8) -> find();
    $qitason = Db::name('slide_item') -> where('slide_id',8) -> select();
    $this -> assign('qtitle',$qita);
    $this -> assign('qitason',$qitason);

    return $this -> fetch();



  }





}
















 ?>