2017-04-09 104 views
0

*我需要在主題下的另一級菜單。請幫助,在此我試圖自2周幫助我理解循環*PHP中的多級菜單與循環

PHP和菜單的HTML代碼,請找到下面

 <!-- Sidebar Menu --> 

     <ul class="sidebar-menu"> 
      <?php 
      if($users->role == "admin" AND $users->customPermissionsType == "custom"){ 
       $userPerm = $users->customPermissionsAsJson(); 
       $performPermScan = true; 
      } 
      while (list($key, $value) = each($panelInit->panelItems)) { 
       if(isset($value['activated']) AND !strpos($panelInit->settingsArray['activatedModules'],$value['activated'])){ continue; } 
       if(!in_array($users->role, $value['permissions'])){ 
        continue; 
       } 
       if(isset($performPermScan) AND isset($value['cusPerm']) AND $value['cusPerm'] != ""){ 
        if(!in_array($value['cusPerm'],$userPerm)){ 
         continue; 
        } 
       } 
       echo "<li "; 
       if(isset($value['children'])){ 
        echo "class='treeview'"; 
       } 
       echo ">"; 
       echo "<a "; 
       if(!isset($value['children'])){ 
        echo "class='aj'"; 
       } 
       if(isset($value['url'])){ 
        echo " href='".URL::to($value['url'])."'"; 
       } 
       echo ">"; 
       echo "<i class='".$value['icon']."'></i><span>"; 
       if(isset($panelInit->language[$value['title']])){ 
        echo $panelInit->language[$value['title']]; 
       }else{ 
        echo $value['title']; 
       } 
       echo "</span>"; 
       if(isset($value['children'])){ 
        echo "<i class='fa fa-angle-left pull-right leftMenuExpand'></i>"; 
       } 
       echo "</a>"; 

       if(isset($value['children'])){ 
        echo '<ul class="treeview-menu">'; 
        while (list($key2, $value2) = each($value['children'])) { 
         if(isset($value2['activated']) AND !strpos($panelInit->settingsArray['activatedModules'],$value2['activated'])){ continue; } 
         if(!in_array($users->role, $value2['permissions'])){ 
          continue; 
         } 
         if(isset($performPermScan) AND isset($value2['cusPerm']) AND $value2['cusPerm'] != ""){ 
          if(!in_array($value2['cusPerm'],$userPerm)){ 
           continue; 
          } 
         } 
         echo "<li>"; 
         echo "<a class='aj' href='".URL::to($value2['url'])."'>"; 
         echo "<i class='".$value2['icon']."'></i> "; 
         if(isset($panelInit->language[$value2['title']])){ 
          echo $panelInit->language[$value2['title']]; 
         }else{ 
          echo $value2['title']; 
         } 
         echo "</a>"; 
         echo "</li>"; 
        } 
        echo "</ul>"; 
       } 

       echo "</li>"; 
      } 
      ?> 
     </ul> 
    </section> 
    <!-- /.sidebar --> 

這是主要的菜單功能,其中我在這裏定義我的菜單

public function __construct(){ 
    $this->panelItems = array(
           "schooladmintasks"=>array("title"=>"School Admin Panel ","icon"=>"fa fa-institution","activated"=>"schadminparentAct","permissions"=>array('admin','teacher','student','parent'),         
                "children"=>array(
                 "classes"=>array("title"=>"classes","url"=>URL::to('#/classes'),"icon"=>"fa fa-check","permissions"=>array('admin')), 
                 "sections"=>array("title"=>"sections","url"=>URL::to('#/sections'),"icon"=>"fa fa-check","permissions"=>array('admin')), 
                 "subjects"=>array("title"=>"Subjects","url"=>URL::to('#/subjects'),"icon"=>"fa fa-check","cusPerm"=>"Subjects","permissions"=>array('admin')),               

                ) 
           ),); 

回答

0

你嘗試

public function __construct(){ 
$this->panelItems = array(
          "schooladmintasks"=>array("title"=>"School Admin Panel ","icon"=>"fa fa-institution","activated"=>"schadminparentAct","permissions"=>array('admin','teacher','student','parent'),         
               "children"=>array(
                "classes"=>array("title"=>"classes","url"=>URL::to('#/classes'),"icon"=>"fa fa-check","permissions"=>array('admin')), 
                "sections"=>array("title"=>"sections","url"=>URL::to('#/sections'),"icon"=>"fa fa-check","permissions"=>array('admin')), 
                "subjects"=>array("title"=>"Subjects","url"=>URL::to('#/subjects'),"icon"=>"fa fa-check","cusPerm"=>"Subjects","permissions"=>array('admin')),     

"thing"=>array("title"=>"Thing","url"=>URL::to('#/thing'),"icon"=>"fa fa-check","cusPerm"=>"Thing","permissions"=>array('admin')), 


               ) 
          ),); 
+0

是的我試過了不工作 – user7839611

+0

Schooladmintasks主菜單,主題子菜單,子菜單下我需要另一個菜單 – user7839611