{{indexmenu_n>600}} ====== Structure Top-Down Output ====== **A snippet catching all available cat-ids behind the given parent id.** * Input: Parent category ID * Output: All available category IDs behind the given id in a string comma separated (Without hidden categories). \\ **Version 1.0** Don“t use it anymore!! function buildStruct_TopDown($start=0) { static $my_cat_id = ''; $struct = getStructureChildData($start); // child data available? foreach($struct as $value) { buildStruct_TopDown($value['acat_id']); $my_cat_id .= $my_cat_id != '' ? ','.$value['acat_id'] : $value['acat_id']; // echo '||'.$value['acat_id'].' ,'; } return $my_cat_id; } \\ **Version 1.1** The right one!! //(Update: KH 25.01.2011)// function buildStruct_TopDown($start=0, &$my_cat_id='') { / KH: V1.1 25.01.2011 $struct = getStructureChildData($start); foreach($struct as $value) { // buildStruct_TopDown($value['acat_id'],$my_cat_id); $my_cat_id .= ($my_cat_id != '') ? ','.$value['acat_id'] : $value['acat_id']; buildStruct_TopDown($value['acat_id'],$my_cat_id); // echo '||'.$value['acat_id'].' ,'; } return $my_cat_id; } \\ ==== Example: ==== Given structure ------------------------------------ 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. ------------------------------------ function call: ##$s = buildStruct_TopDown(2);## //category_02 -> ID=02// Output ##$s##: **4,6,7,5,8** \\ \\ ===== Number of sub-levels ===== Number of categories of the next level when available. echo count(getStructureChildData($GLOBALS['content']['cat_id'])); \\ ==== Is there a sub-level? ==== Simple Script to determine whether there is below the current level, a sub-level. // Sub-Level available? if (!count(getStructureChildData($GLOBALS['content']['cat_id']))) echo 'No Sub-level!'; else echo 'Sub-level available!'; \\