Einzelnen Beitrag anzeigen
  #6 (permalink)  
Alt 03-05-2019, 16:59
sanktusm
 Registrierter Benutzer
Links : Onlinestatus : sanktusm ist offline
Registriert seit: Aug 2005
Beiträge: 651
sanktusm zeigte ein beschämendes Verhalten in der Vergangenheit
Standard Hier die gesammte Klasse: ich bin schon ein wenig weiter gekommen

PHP-Code:

<?php

 
class sections extends header {



  public function 
getTree($menu_area_id$language_id) {

    
$sql "SELECT n.id, n.menu_link,  n.menu_name, n.menu_area, COUNT(*)-1 AS level, n.lft, n.rgt, ROUND ((n.rgt - n.lft - 1) / 2) AS children FROM ".self::PREFIX."sections AS n, ".self::PREFIX."sections AS p WHERE (n.lft BETWEEN p.lft AND p.rgt)
    AND (n.menu_area = '$menu_area_id' AND n.language_id = '"
.$language_id."'
    AND  p.menu_area = '$menu_area_id' AND p.language_id = '"
.$language_id."')
      AND ((n.access_for = '#all' AND p.access_for = '#all')
      OR   (n.access_for IN ("
.$this -> front_users($_SESSION['front_user_id']).") AND p.access_for IN (".$this -> front_users($_SESSION['front_user_id']).")))
       AND ((n.public_status = '2' AND p.public_status = '2')
       OR   (n.public_status = '"
.$_ENV['open_preview']."') AND (p.public_status = '".$_ENV['open_preview']."'))

    GROUP BY n.lft ORDER BY n.lft;"
;
        
$result $this->db->query($sql);

     if(
$this->db->error != "")
     die(
$this->db->error."_getTree");

    
$tree = array();
        
$i 0;
        while (
$row $result->fetch_assoc()) {

            
$tree[$i] = $row;
            
$i++;

        }
        return 
$tree;
    }




    public function 
treeAsHtml($id$menu_area_id$language_id$css_id$css_class$layers) {

    
$tree $this->getTree($menu_area_id$language_id);

    
$level = Array();

    
$html_out_layer "";

        
$html "<ul";

    if(
$css_id != "")
    
$html .= " id=\"".$css_id."\" ";

    if(
$css_class != "")
    
$html .= " class=\"".$css_class."\" ";

    
$html .= ">";

    
$result $this -> selectSimpleSql('navigation''id'$menu_area_id'''''id''ASC');

    
$level_data $result->fetch_assoc();

    
$limits unserialize($level_data['limits']);

    
$close "";



    
$collect_after "";

    
$layer_after "";

    
$layer "";

    
$html_out "";

    
$unblock_ul true;

    
$collect_start_after false;

    
$jump true;

        for (
$i=0$i<count($tree); $i++) {


      
$level $tree[$i]['level'] + 1;

      if(
$tree[$i]['id'] == $_SESSION['id'])
      
$active "active";
      else
      
$active "";





            
$html_li "<li ";  if($limits['li_css_class_'.$level] != "") { $html_li .= "class=\" "$limits['li_css_class_'.$level] . " ".$active."\""; }  $html_li .= ">";


      
$html_link "<a href=\"?id=" $tree[$i]['id'] . "\" "; if($limits['tag_css_class_'.$level] != "") { $html_link .= " class=\""$limits['tag_css_class_'.$level] . "\""; }  $html_link .=  " >" $tree[$i]['menu_name'] . "</a>";




      if(
$layers['enclose_tag_level_'.$level] != "") {

          
$html_li .= str_replace('|'$html_link$layers['enclose_tag_level_'.$level]);

      } else {

          
$html_li .= $html_link;
      }



      if(
$tree[$i]['level'] == $tree[$i+1]['level'] OR $tree[$i]['level'] > $tree[$i+1]['level']) {

        
$html_li .= "</li>";


        
$html_ul .= $html_li;

      }

      if(
$layers['html_container_'.$level] != "" AND $layers['enclose_before_after_tag_'.$level] == 1)  {

      
$collect_start_before true;

      
$layer_before $layers['html_container_'.$level];

      
$unblock_ul false;

      }


      if(
$tree[$i]['level'] < $tree[$i+1]['level']) {

        
$html_ul .= $html_li;




         
$html_ul .= "<ul"; if($limits['ul_css_class_'.$level] != "") { $html_ul .= " class=\""$limits['ul_css_class_'.$level] . "\""; }  $html_ul .=  ">";







            } else if (
$tree[$i]['level'] > $tree[$i+1]['level']) {

        
$diff $tree[$i]['level'] - $tree[$i+1]['level'];

                
$html_close str_repeat("</ul></li>"$diff) . "";

        switch(
$diff) {


        case 
1:

        
$collect_start_before == true;

        
$html_ul .= $html_close;

        break;

        case 
2:

        
$collect_after .= $html_ul;

        
$collect_after .= "</ul></li>";

        
$html_out .= str_replace('|'$collect_after$layer_after);

        
$html_out .= "</ul></li>";

        
$collect_start_after false;

        
$unblock_ul false;

        break;

        default:

        
$collect_start_before == false;

        
$html_ul .= $html_close;

      }

      }





      if(
$collect_start_after === true) {

        if(
$tree[$i]['level'] > $tree[$i+1]['level']) {


        
$collect_before str_replace('|'$collect_after$layer_before);

        
$collect_after "";

        
$collect_after .= $collect_before;

        
$collect_before "";

      } else {


         
$collect_before "";

         
$collect_start_before == true;

         
$collect_after .= $html_ul;

       }



      
$unblock_ul false;

      }





      if(
$layers['html_container_'.$level] != "" AND $layers['enclose_before_after_tag_'.$level] == AND $tree[$i]['children'] > 0) {

      
$collect_after "";

      
$collect_start_before == false;

      
$layer_after $layers['html_container_'.$level];

      
$collect_start_after true;



      }




      
$active "";

      if(
$unblock_ul === true) {

      
$html_out .= $html_ul;

      
$html_ul .= $html_close;

      }

      
$html_ul "";

      
$unblock_ul true;

      }


      
$html .= $html_out;

        
$html .= "</ul>";



    return 
$html;

    }




  }
?>
Das Ergebniss ist leider immer noch dieses: Die Menupunkte werden unvollständig ausgeben und die Layer <div class="col-sm-3 col-xs-6"> stehen am Anfang doppelt und im letzten Block gar nicht. Ich arbeit jetzt schon eine Woche daran. Ich brauche Eure Hilfe

Die $layers sehen so aus:

Array
(
[level_1] => 10
[ul_css_class_1] =>
[li_css_class_1] => menu-el
[tag_layer_1] => a
[tag_css_class_1] =>
[enclose_tag_level_1] =>
[enclose_before_after_tag_1] => 2
[html_container_1] => <div class="mdf_sub_wrap mdf_flip row lists">|</div>
[level_2] => 10
[ul_css_class_2] => mdf_child_menu
[li_css_class_2] =>
[tag_layer_2] => h3
[tag_css_class_2] =>
[enclose_tag_level_2] => <div class="cl-title">|</div>
[enclose_before_after_tag_2] => 1
[html_container_2] => <div class="col-sm-3 col-xs-6">|</div>
)

PHP-Code:


<div id="sticky-navbar" class="container-fluid full-navbar">
  <
nav id="mdf_menu" class="navbar navbar-default"  role="navigation">

      <
div id="navbar" class="collapse navbar-collapse">

        <
ul class="nav navbar-nav mr-auto" >
            <
li class=" menu-el active"><a href="" >Home</a></li>
            <
li class=" menu-el "><a>Produkte</a>
                <
ul><div class="mdf_sub_wrap mdf_flip row lists">
                         <
div class="col-sm-3 col-xs-6"><div class="col-sm-3 col-xs-6">
                              <
li ><div class="cl-title"><h3>Aluund Stahlprodukte </h3></div>
                                  <
ul class="mdf_child_menu">
                                      <
li ><a href="alu-stahl-trapezblech" >Trapezbleche</a></li>
                                      <
li ><a href="wellblech-guenstig" >Wellbleche</a></li>
                                    </
div>
                                    <
li ><div class="cl-title"><a href="befestigung-dach" >Befestigung und Abdichtung</a></div>
                                  <
ul class="mdf_child_menu">
                                      <
li ><a href="schrauben-dachplatten" >Schrauben</a></li>
                                      <
li ><a href="kalotten-trapezblech" >Kalotten</a></li>
                                      <
li ><a href="profilfueller-dach" >Profilfüller</a></li></div>
                                 <
li ><div class="cl-title"><a href="dachzubehoer-online-shop" >Dachzubehör für Verleger</a></div>
                                    <
ul class="mdf_child_menu">
                                       <
li ><a href="unterdeck-unterspannbahn-und-zubehoer" >Unterdeck-Unterspannbahn und Zubehör</a></li>
                                       <
li ><a href="dachentwaesserungssysteme" >Dachentwässerungssysteme</a></li>
                                       <
li ><a href="schneefangsysteme-und-zubehoer" >Schneefangsysteme und Zubehör</a></li>
                                    </
ul>
                                </
li>
                                </
div>
                                </
ul></li>
                                <
li class=" menu-el "><a>Anwendungen</a>
                                     <
ul><div class="mdf_sub_wrap mdf_flip row lists">
                                         <
li ><div class="cl-title"><h3>Anwendungen Aluund Stahlrodukte</h3></div>
                                         <
ul class="mdf_child_menu">
                                             <
li ><a>Carport mit Trapezblech</a></li>
                                             <
li ><a>GartenhausSchuppendach mit Aluminium Trapezblech</a></li>
                                             <
li ><a>GartenhausSchuppendach mit Ziegelblech</a></li>
                                             <
li ><a>Dachsysteme für das Wohnhaus</a></li>
                                          </
ul>
                                  </
li></div>
                                  </
ul></li>
                                  <
li class=" menu-el "><a href="dachkonfigurator" >Unser Dachkonfigurator</a></li>
                                  <
li class=" menu-el "><a href="montage-dachplatten-unser-forum" >Kundenforum</a></li></ul>

            

      </
div>


    </
nav>
  </
div

Geändert von sanktusm (03-05-2019 um 17:04 Uhr)
Mit Zitat antworten