This is an old revision of the document!


Struktur Bottom-Top Ausgabe

Ein Programmteil das alle verfügbaren Kategorie-IDs oberhalb der angegebenen Ebene bis zur angegebenen übergeordneten Ebene ausgibt.

Anders ausgedrückt: Ist die aktuelle Kategorie ein Teil der Unterkategorien von der angegebenen übergeordneten Kategorie?

  • Eingabe: Aktuelle Kategorie-ID ($start), übergeordnete Kategorie-ID ($top > 0)
  • Rückgabe:
    1. bei Erfolg: String kommasepariert mit allen IDs des abgesuchten Strukturbaums
    2. bei Nichterfolg: Leerer String = ''


buildStruct_BottomTop

function buildStruct_DownTop($start=0, $top=0) {
 
/**
 * -----------------------------------------------------------------------------
 * v1.0 KH (flip-flop) 23.08.2010
 * Structure bottom->top  given: Actual cat-ID (start) and parent cat-id (top > 0)
 * Are the current category a part of the subcategories of the given parent category?
 * Return:
 * - on success: String separated by commas with all the IDs of the searched tree structure
 * - on failure: Empty string =''
 *
 * Struktur bottom->top  gegeben: Aktuelle cat-ID (start) und uebergeordnete cat-id (top > 0)
 * Ist die aktuelle Kategorie ein Teil der Unterkategorien von der gegebenen uebergeordneten Kategorie
 * Rueckgabe:
 * - bei Erfolg: String kommasepariert mit allen IDs des abgesuchten Strukturbaums
 * - bei Nichterfolg: Leerer String = ''
 * -----------------------------------------------------------------------------
 */
 
    if ($top > 0) { // only IDs > root level
 
        $stop     = false;
        $cat_id    = $start;
 
        while (!$stop ) {
 
            $start = $GLOBALS['content']["struct"][$start]['acat_struct']; // Parent cat
 
            $cat_id .= ($cat_id != '') ? ','.$start : $start;
 
            if ($start == $top OR $start == 0) $stop = true;
            if ($start == 0) $cat_id = '';  // delete all entries, there is no match
 
        } // END while
    } // END if
 
    return $cat_id;
 
} // ===== END function


Beispiel:

Gegebene Struktur

 ------------------------------------
L  E  V  E  L
.:  :  :  :
.0  1  2  3   <- LEVEL-Nr.
.:  :  :  :
-+ home   :                    ID=0
-+--+ category_01              ID=01
-+--+ category_02              ID=02
-+--+--+ category_02_01        ID=04
-+--+--+--+ category_02_01_01  ID=06
-+--+--+--+ category_02_01_02  ID=07
-+--+--+ category_02_01        ID=05
-+--+--+ category_02_02        ID=08
-+--+ category_03              ID=03
-+--+ category_04              ID=09
.:  :  :  :
.0  1  2  3   <- LEVEL Nr.
------------------------------------


Funktionsaufruf: $s = buildStruct_BottomTop(7, 2); category_02_01_02 → ID=07, category_02 → ID=02

Ausgabe $s: 7,4,2


Funktionsaufruf: $s = buildStruct_BottomTop(7, 3); category_02_01_02 → ID=07, category_03 → ID=03

Ausgabe $s: '' → Der String ist leer, da die Kategorie ID=7 nicht unterhalb der Kategorie ID=3 liegt.

deutsch/technik/aufruf-interner-funktionen/kategorie-bottom-top.1282562821.txt.gz · Last modified: 2018/06/03 18:06 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0