Ankündigung

Einklappen
Keine Ankündigung bisher.

Rekursiver Funktionsaufruf

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Rekursiver Funktionsaufruf

    Hallo miteinander,

    versuche seit einigen Tagen eine Funktion zu schreiben, die rekursiv aufgerufen werden kann. Der Zweck ist das erstellen eines Baum Menüs. Ein Eintrag im Menü soll nur angezeigt werden, wenn zum Eintrag mindestens ein Artikel aktiviert ist.

    Leider scheitere ich beim Aufruf der zweiten foreach Schleife in der Funktion tep_push_category mit der Fehlermeldung "Invalid argument supplied for foreach()". Die ersten zwei Ebenen kann ich problemlos an das Array anfügen.

    Poste hier mal den stark reduzierten Code und das Array so wie es bisher aussieht und wie es aussehen sollte. Die Datenbank Tabellen habe ich aufgrund der Größenbeschränkung im Forum nicht ablegen können.

    Beste Grüße und vielen Dank für jeden Hinweis

    Leonhard

    PHP-Code:
    <?php
      
    //-----------------------------------------------------------------
      // Search parent categorie and insert child categorie in menu tree
      
    function tep_push_category$tree$categories$level ) {
        
    $exists false;

        
    // Check if the parent categories id exists in this level
        
    if( array_key_exists$categories['parent_id'], $tree ) ) {
          
    // Insert menu entry in the current menu level
          
    $tree[$categories['parent_id']]['sub'][$categories['categories_id']] = array( 'name'   => $categories['categories_name'],
                                                                                        
    'parent' => $categories['parent_id'],
                                                                                        
    'sub'    => array() );
          
    $exists true;
        } else {
          
    // Check if the parent categories id exists in a sub level menu of the current menu level
          
    $level++;

          foreach( 
    $tree as $tree_detail ) {
            
    // Check all entries in array named sub
            
    foreach( $tree_detail['sub'] as $tree_sub_detail ) {
              
    // Recursive function request
              
    if( tep_push_category$tree_sub_detail$categories, &$level ) ) {
                
    $exists true;
                break 
    2;
              }
            }
          }

          
    $level--;
        }

        return 
    $exists;
      }

      
    //////////////////////////////////////////////////////////////////
      
    $tree = array();

      
    // Select each level of categories menu
      // Insert menu entry only if a product in menu level or sub menu levels is active
      
    $categories_query_raw "select c.categories_id, cd.categories_name, c.parent_id, " .
                                     
    "count( p.products_id ) as total " .
                                
    "from categories as c " .
                                
    "join categories_description as cd " .
                                  
    "on cd.categories_id = c.categories_id " .
                                 
    "and cd.language_id   = '2' " .
                                
    "left join products_to_categories as ptc " .
                                  
    "on ptc.categories_id = c.categories_id " .
                                
    "left join products as p " .
                                  
    "on p.products_id     = ptc.products_id " .
                                 
    "and p.products_status = '1' " .
                                
    "group by c.categories_id " .
                                
    "order by c.sort_order, c.parent_id, cd.categories_name";
      
    $categories_query     tep_db_query$categories_query_raw );

      while( 
    $categories tep_db_fetch_array$categories_query ) ) {
        if( 
    $categories['parent_id'] == '0' ) {
          
    // Collect first level of categories menu
          
    $tree[$categories['categories_id']]= array( 'name' => $categories['categories_name'],
                                                      
    'parent' => $categories['parent_id'],
                                                      
    'sub'  => array() );
        } else {
          
    // Collect second, third, etc. level of categories menu
          
    tep_push_category( &$tree$categories);
        }
      }

    print_r$tree );
    ?>
    Das Array so wie es bisher aussieht
    PHP-Code:
    Array (  [1] => Array ( [name] => Cerealien     [parent] => [sub] => Array (  [2] => Array ( [name] => Flakes   [parent] =>  [sub] => Array ( ) )
                                                                                    [
    3] => Array ( [name] => Flocken  [parent] =>  [sub] => Array ( ) )
                                                                                    [
    4] => Array ( [name] => Krunchy  [parent] =>  [sub] => Array ( ) )
                                                                                    [
    5] => Array ( [name] => Müsli    [parent] =>  [sub] => Array ( ) )
                                                                                    [
    6] => Array ( [name] => Pops     [parent] =>  [sub] => Array ( ) ) ) )
             [
    7] => Array ( [name] => Getreide      [parent] => [sub] => Array (  [8] => Array ( [name] => Dinkel   [parent] =>  [sub] => Array ( ) )
                                                                                    [
    9] => Array ( [name] => Fünfkorn [parent] =>  [sub] => Array ( ) )
                                                                                   [
    10] => Array ( [name] => Gerste   [parent] =>  [sub] => Array ( ) )
                                                                                   [
    11] => Array ( [name] => Hafer    [parent] =>  [sub] => Array ( ) )
                                                                                   [
    12] => Array ( [name] => Roggen   [parent] =>  [sub] => Array ( ) )
                                                                                   [
    13] => Array ( [name] => Weizen   [parent] =>  [sub] => Array ( ) ) ) )
            [
    14] => Array ( [name] => Griess        [parent] => [sub] => Array ( [15] => Array ( [name] => Dinkel   [parent] => 14 [sub] => Array ( ) ) ) )
            [
    16] => Array ( [name] => Kissenfüllung [parent] => [sub] => Array ( [17] => Array ( [name] => Spelzen  [parent] => 16 [sub] => Array ( ) ) ) )
            [
    18] => Array ( [name] => Mehl          [parent] => [sub] => Array ( [19] => Array ( [name] => Dinkel   [parent] => 18 [sub] => Array ( ) )
                                                                                   [
    20] => Array ( [name] => Roggen   [parent] => 18 [sub] => Array ( ) )
                                                                                   [
    21] => Array ( [name] => Weizen   [parent] => 18 [sub] => Array ( ) ) ) )
            [
    22] => Array ( [name] => Spezialitäten [parent] => [sub] => Array ( [23] => Array ( [name] => Hirse    [parent] => 22 [sub] => Array ( ) ) ) ) ) 
    Das Array so wie es aussehen sollte mit den Einträgen "ungeschält" und "geschält"
    PHP-Code:
    Array (  [1] => Array ( [name] => Cerealien     [parent] => [sub] => Array (  [2] => Array ( [name] => Flakes   [parent] =>  [sub] => Array ( ) )
                                                                                    [
    3] => Array ( [name] => Flocken  [parent] =>  [sub] => Array ( ) )
                                                                                    [
    4] => Array ( [name] => Krunchy  [parent] =>  [sub] => Array ( ) )
                                                                                    [
    5] => Array ( [name] => Müsli    [parent] =>  [sub] => Array ( ) )
                                                                                    [
    6] => Array ( [name] => Pops     [parent] =>  [sub] => Array ( ) ) ) )
             [
    7] => Array ( [name] => Getreide      [parent] => [sub] => Array (  [8] => Array ( [name] => Dinkel   [parent] =>  [sub] => Array ( ) )
                                                                                    [
    9] => Array ( [name] => Fünfkorn [parent] =>  [sub] => Array ( ) )
                                                                                   [
    10] => Array ( [name] => Gerste   [parent] =>  [sub] => [27] => Array ( [name] => ungeschält  [parent] => 10 [sub] => Array ( ) )
                                                                                                                                              [
    28] => Array ( [name] => geschält    [parent] => 10 [sub] => Array ( ) ) )
                                                                                   [
    11] => Array ( [name] => Hafer    [parent] =>  [sub] => Array ( ) )
                                                                                   [
    12] => Array ( [name] => Roggen   [parent] =>  [sub] => Array ( ) )
                                                                                   [
    13] => Array ( [name] => Weizen   [parent] =>  [sub] => Array ( ) ) ) )
            [
    14] => Array ( [name] => Griess        [parent] => [sub] => Array ( [15] => Array ( [name] => Dinkel   [parent] => 14 [sub] => Array ( ) ) ) )
            [
    16] => Array ( [name] => Kissenfüllung [parent] => [sub] => Array ( [17] => Array ( [name] => Spelzen  [parent] => 16 [sub] => Array ( ) ) ) )
            [
    18] => Array ( [name] => Mehl          [parent] => [sub] => Array ( [19] => Array ( [name] => Dinkel   [parent] => 18 [sub] => Array ( ) )
                                                                                   [
    20] => Array ( [name] => Roggen   [parent] => 18 [sub] => Array ( ) )
                                                                                   [
    21] => Array ( [name] => Weizen   [parent] => 18 [sub] => Array ( ) ) ) )
            [
    22] => Array ( [name] => Spezialitäten [parent] => [sub] => Array ( [23] => Array ( [name] => Hirse    [parent] => 22 [sub] => Array ( ) ) ) ) ) 

  • #2
    Moin,

    "Invalid argument supplied for foreach()" das kommt weil $tree_detail['sub'] eben kein array ist sondern gar nichts, das würdest du sehen wenn du deine array-ansicht mal ordentlich einrücken würdest.

    Dein ['sub'] ist erst in der dritten Ebene

    Kommentar


    • #3
      Hallo cycap,

      Zitat von cycap Beitrag anzeigen
      Moin,

      "Invalid argument supplied for foreach()" das kommt weil $tree_detail['sub'] eben kein array ist sondern gar nichts, das würdest du sehen wenn du deine array-ansicht mal ordentlich einrücken würdest.

      Dein ['sub'] ist erst in der dritten Ebene
      Danke für den Hinweis. Meinst Du das mit dem Einrücken so:
      PHP-Code:
      Array
      (
          [
      a] => Apfel
          
      [b] => Banane
          
      [c] => Array
              (
                  [
      0] => x
                  
      [1] => y
                  
      [2] => z
              
      )

      Ein print_r() nach der ersten foreach Schleife gibt mir z.B. folgendes Array aus:
      PHP-Code:
      Array
      (
          [
      2] => Array
              (
                  [
      name] => Flakes
                  
      [parent] => 1
                  
      [sub] => Array
                      (
                      )

              )

          [
      3] => Array
              (
                  [
      name] => Flocken
                  
      [parent] => 1
                  
      [sub] => Array
                      (
                      )

              )

          [
      4] => Array
              (
                  [
      name] => Krunchy
                  
      [parent] => 1
                  
      [sub] => Array
                      (
                      )

              )

          [
      5] => Array
              (
                  [
      name] => Müsli
                  
      [parent] => 1
                  
      [sub] => Array
                      (
                      )

              )

          [
      6] => Array
              (
                  [
      name] => Pops
                  
      [parent] => 1
                  
      [sub] => Array
                      (
                      )

              )


      Beste Grüße

      Leonhard

      Kommentar


      • #4
        Hmm das verwirrt mich jetzt. Jetzt sehe ich aber wenigstens etwas mehr

        Was sagt denn ein print_r direkt vor der ersten foreach und ein print_r($tree_detail) vor der zweiten foreach (also innnerhalb des ersten) ?

        Kommentar


        • #5
          Hallo cycap,

          habe das ganze Coding so umgeschrieben, das man es auch ohne Datenbank laufen lassen kann.

          PHP-Code:
          <?php
            error_reporting
          E_ALL & ~E_NOTICE );

            
          //-----------------------------------------------------------------
            // Search parent categorie and insert child categorie in menu tree
            
          function tep_push_category$tree$categories$level ) {
              
          $exists false;

              
          // Check if the parent categories id exists in this level
              
          if( array_key_exists$categories['parent_id'], $tree ) ) {
                
          // Insert menu entry in the current menu level
                
          $tree[$categories['parent_id']]['sub'][$categories['categories_id']] = array( 'name'   => $categories['categories_name'],
                                                                                              
          'parent' => $categories['parent_id'],
                                                                                              
          'sub'    => array() );
                
          $exists true;
              } else {
                
          // Check if the parent categories id exists in a sub level menu of the current menu level
                
          $level++;

              
          //print_r( $tree );

                
          foreach( $tree as $tree_detail ) {
                
          //print_r( $tree_detail );
                  // Check all entries in array named sub
                  
          foreach( $tree_detail['sub'] as $tree_sub_detail ) {
                    
          // Recursive function request
                    
          if( tep_push_category$tree_sub_detail$categories, &$level ) ) {
                      
          $exists true;
                      break 
          2;
                    }
                  }
                }

                
          $level--;
              }

              return 
          $exists;
            }

            
          //////////////////////////////////////////////////////////////////
          /*
            Folgende Ausgabe liefert der select      

            categories_id|categories_name|parent_id|total|
                        1|Cerealien      |        0|    0|
                        7|Getreide       |        0|    0|
                       14|Griess         |        0|    0|
                       16|Kissenfüllung  |        0|    0|
                       18|Mehl           |        0|    0|
                       22|Spezialitäten  |        0|    0|
                        2|Flakes         |        1|    1|
                        3|Flocken        |        1|    6|
                        4|Krunchy        |        1|    2|
                        5|Müsli          |        1|    3|
                        6|Pops           |        1|    3|
                        8|Dinkel         |        7|    0|
                        9|Fünfkorn       |        7|    0|
                       10|Gerste         |        7|    0|
                       11|Hafer          |        7|    0|
                       12|Roggen         |        7|    0|
                       13|Weizen         |        7|    0|
                       28|geschält       |       10|    0|
                       27|ungeschält     |       10|    0|
                       15|Dinkel         |       14|    0|
                       17|Spelzen        |       16|    3|
                       19|Dinkel         |       18|    3|
                       20|Roggen         |       18|    0|
                       21|Weizen         |       18|    0|
                       23|Hirse          |       22|    0|
          */
            
          $categories_array[] = array( 'categories_id'   => '1',
                                         
          'categories_name' => 'Cerealien',
                                         
          'parent_id'       => '0',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '7',
                                         
          'categories_name' => 'Getreide',
                                         
          'parent_id'       => '0',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '14',
                                         
          'categories_name' => 'Griess',
                                         
          'parent_id'       => '0',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '16',
                                         
          'categories_name' => 'Kissenfüllung',
                                         
          'parent_id'       => '0',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '18',
                                         
          'categories_name' => 'Mehl',
                                         
          'parent_id'       => '0',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '22',
                                         
          'categories_name' => 'Spezialitäten',
                                         
          'parent_id'       => '0',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '2',
                                         
          'categories_name' => 'Flakes',
                                         
          'parent_id'       => '1',
                                         
          'total'           => '1' );

            
          $categories_array[] = array( 'categories_id'   => '3',
                                         
          'categories_name' => 'Flocken',
                                         
          'parent_id'       => '1',
                                         
          'total'           => '6' );

            
          $categories_array[] = array( 'categories_id'   => '4',
                                         
          'categories_name' => 'Krunchy',
                                         
          'parent_id'       => '1',
                                         
          'total'           => '2' );

            
          $categories_array[] = array( 'categories_id'   => '5',
                                         
          'categories_name' => 'Müsli',
                                         
          'parent_id'       => '1',
                                         
          'total'           => '3' );

            
          $categories_array[] = array( 'categories_id'   => '6',
                                         
          'categories_name' => 'Pops',
                                         
          'parent_id'       => '1',
                                         
          'total'           => '3' );

            
          $categories_array[] = array( 'categories_id'   => '8',
                                         
          'categories_name' => 'Dinkel',
                                         
          'parent_id'       => '7',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '9',
                                         
          'categories_name' => 'Fünfkorn',
                                         
          'parent_id'       => '7',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '10',
                                         
          'categories_name' => 'Gerste',
                                         
          'parent_id'       => '7',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '11',
                                         
          'categories_name' => 'Hafer',
                                         
          'parent_id'       => '7',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '12',
                                         
          'categories_name' => 'Roggen',
                                         
          'parent_id'       => '7',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '13',
                                         
          'categories_name' => 'Weizen',
                                         
          'parent_id'       => '7',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '28',
                                         
          'categories_name' => 'geschält',
                                         
          'parent_id'       => '10',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '27',
                                         
          'categories_name' => 'ungeschält',
                                         
          'parent_id'       => '10',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '15',
                                         
          'categories_name' => 'Dinkel',
                                         
          'parent_id'       => '14',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '17',
                                         
          'categories_name' => 'Spelzen',
                                         
          'parent_id'       => '16',
                                         
          'total'           => '3' );

            
          $categories_array[] = array( 'categories_id'   => '19',
                                         
          'categories_name' => 'Dinkel',
                                         
          'parent_id'       => '18',
                                         
          'total'           => '3' );

            
          $categories_array[] = array( 'categories_id'   => '20',
                                         
          'categories_name' => 'Roggen',
                                         
          'parent_id'       => '18',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '21',
                                         
          'categories_name' => 'Weizen',
                                         
          'parent_id'       => '18',
                                         
          'total'           => '0' );

            
          $categories_array[] = array( 'categories_id'   => '23',
                                         
          'categories_name' => 'Hirse',
                                         
          'parent_id'       => '22',
                                         
          'total'           => '0' );
            
          $tree = array();

            foreach( 
          $categories_array as $categories ) {
              if( 
          $categories['parent_id'] == '0' ) {
                
          // Collect first level of categories menu
                
          $tree[$categories['categories_id']]= array( 'name'   => $categories['categories_name'],
                                                            
          'parent' => $categories['parent_id'],
                                                            
          'sub'    => array() );
              } else {
                
          // Collect second, third, etc. level of categories menu
                
          tep_push_category( &$tree$categories);
              }
            }

          //print_r( $tree );
          ?>
          Beste Grüße
          Mike

          Kommentar


          • #6
            Hallo,

            mit einem Codebeispiel unter folgendem Link kann ich das Array nun erstellen:

            Baumstruktur aus DB in Array abbilden - php bar

            Der Code sieht nun folgendermaßen aus:
            PHP-Code:
              $categories_query_raw "select c.categories_id, cd.categories_name, c.parent_id, " .
                                             
            "count( p.products_id ) as total " .
                                        
            "from categories as c " .
                                        
            "join categories_description as cd " .
                                          
            "on cd.categories_id = c.categories_id " .
                                         
            "and cd.language_id   = '2' " .
                                        
            "left join products_to_categories as ptc " .
                                          
            "on ptc.categories_id = c.categories_id " .
                                        
            "left join products as p " .
                                          
            "on p.products_id     = ptc.products_id " .
                                         
            "and p.products_status = '1' " .
                                        
            "group by c.categories_id " .
                                        
            "order by c.sort_order, c.parent_id, cd.categories_name";
              
            $categories_query     tep_db_query$categories_query_raw );

              while( 
            $categories tep_db_fetch_array$categories_query ) ) {
                
            $cat[] = $categories;
              }

              for( 
            $i 0$j count$cat ); $i $j$i++ ) {
                
            // Selektierte Felder in unserem Array ablegen
                
            foreach( $cat[$i] as $key => $val ) {
                  
            $tree[$cat[$i]['categories_id']][$key] = $val;
                }

                
            // verlinken mit dem Elternteil
                
            $tree[$cat[$i]['parent_id']]['childs'][$cat[$i]['categories_id']] =& $tree[$cat[$i]['categories_id']];
              }

              
            print_r$tree[0] ); 
            Das Array kann ich nun auslesen. Das Ändern oder Löschen von Array Einträge versuche ich jetzt gerade. Leider gelingt mir das bisher noch nicht.

            Beste Grüße
            Mike Leonhard

            Kommentar


            • #7
              Zitat von Leonhard Beitrag anzeigen
              Hallo,

              Das Array kann ich nun auslesen. Das Ändern oder Löschen von Array Einträge versuche ich jetzt gerade. Leider gelingt mir das bisher noch nicht.

              Beste Grüße
              Mike Leonhard
              Guten Tag zusammen,

              vom Löschen von Array Einträgen habe ich nun Abstand genommen, da der Array Index beim Löschen eines Eintrages jeweils neu durchnummeriert wird. Statt dessen weise ich nun dem Feld total den summierten Wert zu und prüfe bei der Ausgabe, ob dieses Feld einen Wert > 0 enthält. An folgendem Code kann man dieses nachvollziehen.
              PHP-Code:
              <?php
                
              //////////////////////////////////////////////////////////////////
                // Select each level of categories menu
                // Insert menu entry only if a product in menu level or sub menu levels is active
                // Use always 0 in select as indicator for first level
                
              $categories_query_raw "select c.categories_id, cd.categories_name, c.parent_id, " .
                                               
              "count( p.products_id ) as total, " .
                                               
              "0 as level " .
                                          
              "from categories as c " .
                                          
              "join categories_description as cd " .
                                            
              "on cd.categories_id = c.categories_id " .
                                           
              "and cd.language_id   = '2' " .
                                          
              "left join products_to_categories as ptc " .
                                            
              "on ptc.categories_id = c.categories_id " .
                                          
              "left join products as p " .
                                            
              "on p.products_id     = ptc.products_id " .
                                           
              "and p.products_status = '1' " .
                                        
              //"where c.categories_active = '1' " .
                                          
              "group by c.categories_id " .
                                          
              "order by c.sort_order, c.parent_id, cd.categories_name";
                
              $categories_query     tep_db_query$categories_query_raw );

                while( 
              $categories tep_db_fetch_array$categories_query ) ) {
                  
              $cat[] = $categories;
                }

                for( 
              $i 0$j count$cat ); $i $j$i++ ) {
                  
              // Store selected fields in array
                  
              foreach( $cat[$i] as $key => $val ) {
                    
              $tree[$cat[$i]['categories_id']][$key] = $val;
                  }

                  
              // Create a reference to parent category
                  
              $tree[$cat[$i]['parent_id']]['childs'][$cat[$i]['categories_id']] =& $tree[$cat[$i]['categories_id']];
                }

                
              tep_count_articles_in_menu$tree[0], $tree, -10);

                
              $categories_string '';

                
              tep_show_category$tree[0], $cPath_array''$categories_string );

              //print_r( $tree );
              //print_r( '<br>' );
                
              print_r$categories_string );

                
              //-----------------------------------------------------------------
                // Count quantity of articles of each menu entry and save in the parent category
                
              function tep_count_articles_in_menu( &$tree, &$tree_all$level$total ) {

                  if( isset( 
              $tree['categories_id'] ) ) {
                    
              // Save the current level of menu entry
                    
              $tree_all[$tree['categories_id']]['level'] = $level;
                  }

                  
              // Check if the current category has one or more sub categories
                  
              if( isset( $tree['childs'] ) ) {
                    
              $level++;

                    
              // Init counter with the quantity of parent category
                    
              $total $tree['total'];

                    foreach( 
              $tree['childs'] as $tree_sub ) {
                      
              // Processing one or more sub categories
                      
              $total tep_count_articles_in_menu$tree_sub$tree_all, &$level$total );
                    }

                    if( 
              $total ) {
                      
              // Save the counted quantity of active articles from the parent and sub category in the parent category
                      
              $tree_all[$tree['categories_id']]['total'] = $total;
                    }

                    
              $level--;
                  } else {
                    
              // Check if menu entry has an activated article.
                    
              if( $tree['total'] > ) {
                      
              // Count quantity of articles
                      
              $total += $tree['total'];
                    }
                  }

                  return 
              $total;
                }

                
              //-----------------------------------------------------------------
                // Display menu entry only if an article in menu level or sub menu level is active
                
              function tep_show_category( &$tree, &$c_path_array$c_path_parent, &$categories_string ) {

                  
              // Output only category if an article is active (total > 0)
                  
              if( isset( $tree['categories_id'] ) && $tree['total'] > ) {
                    if( 
              $tree['level'] > ) {
                      
              // Pre spaces for sub menu
                      
              for( $i 0$j $tree['level']; $i $j$i++ ) {
                        
              $categories_string .= "&nbsp;&nbsp;";
                      }

                      
              // Concatenate the categories id with underline
                      
              $c_path '_' $tree['categories_id'];

                      
              // Only append categories id as from level 1
                      
              $c_path_param $c_path_parent '_' $tree['categories_id'];
                    } else {
                      
              // Reset the cPath variable
                      
              $c_path_parent $tree['categories_id'];
                      
              $c_path        '';
                      
              $c_path_param  $c_path_parent;
                    }

                    
              // Create the first part of category link
                    
              $categories_string .= '<a href="' tep_href_linkFILENAME_DEFAULT'cPath=' $c_path_parent $c_path ) . '">';

                    
              // Output the category name
                    
              $categories_string .= $tree['categories_name'];
                    
              $categories_string .= '</a>';
                    
              $categories_string .= '<br>';
                  }

                  
              // Check if the current category has one or more sub categories
                  
              if( isset( $tree['childs'] ) ) {
                    
              $process true;

                    
              // Check if the menu entry has active article
                    
              if( isset( $tree['total'] ) && $tree['total'] < ) {
                      
              // No active article available do not process childs
                      
              $process false;
                    }

                    if( 
              $process ) {
                      
              // Processing one or more sub categories
                      
              foreach( $tree['childs'] as $tree_sub ) {
                        
              tep_show_category$tree_sub$cPath_array$c_path_param$categories_string );
                      }
                    }
                  }
                }
              ?>
              Schönen Tag
              Mike Leonhard

              Kommentar

              Lädt...
              X