{{indexmenu_n>610}} ====== Structure Bottom-Top Output ====== **A snippet catching all available cat-ids between the specified level to the specified parent level.** In other words: Is the current category a part of the subcategories of the given parent category? * **Input:** Actual category-ID //($start)//, parent category-ID (//%%$top > 0%%)// * **Return:** - on success: String separated by commas with all the IDs of the searched tree structure - on failure: %%Empty string = ''%% \\ 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) * Is 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 \\ ==== Example: ==== Given structure ------------------------------------ L E V E L .: : : : .0 1 2 3 <- LEVEL-No. .: : : : -+ 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 No. ------------------------------------ \\ Function call: ##$s = buildStruct_BottomTop(7, 2);## //category_02_01_02 -> ID=07, category_02 -> ID=02// Output ##$s##: **7,4,2** \\ Function call: ##$s = buildStruct_BottomTop(7, 3);## //category_02_01_02 -> ID=07, category_03 -> ID=03// Output ##$s##: **%%''%%** -> The string is empty because the category %%ID=7%% is not within the structure of the category tree from category %%ID=3%% .