NAVIGATION
This shows you the differences between two versions of the page.
english:technics:internal-function-call:category-top-down [2009/05/24 12:45] Knut Heermann (flip-flop) Page moved from english:technics:internally-function-call:category-top-down to english:technics:internal-function-call:category-top-down |
english:technics:internal-function-call:category-top-down [2018/06/03 18:09] (current) |
||
---|---|---|---|
Line 9: | Line 9: | ||
\\ | \\ | ||
- | <code php> | + | <del>**Version 1.0**</del> Don´t use it anymore!! |
+ | <code php |h StructureTopDown_v1.0 |h> | ||
function buildStruct_TopDown($start=0) { | function buildStruct_TopDown($start=0) { | ||
Line 28: | Line 29: | ||
} | } | ||
</code> | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | **Version 1.1** The right one!! //(Update: KH 25.01.2011)// | ||
+ | |||
+ | <code php |h StructureTopDown_v1.1 |h> | ||
+ | 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; | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
==== Example: ==== | ==== Example: ==== | ||
Line 57: | Line 83: | ||
Output ##$s##: **4,6,7,5,8** | Output ##$s##: **4,6,7,5,8** | ||
+ | \\ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | ===== Number of sub-levels ===== | ||
+ | |||
+ | Number of categories of the next level when available. | ||
+ | |||
+ | <code php> | ||
+ | echo count(getStructureChildData($GLOBALS['content']['cat_id'])); | ||
+ | </code> | ||
+ | |||
+ | \\ | ||
+ | |||
+ | |||
+ | ==== Is there a sub-level? ==== | ||
+ | |||
+ | Simple Script to determine whether there is below the current level, a sub-level. | ||
+ | |||
+ | <code php> | ||
+ | // Sub-Level available? | ||
+ | |||
+ | if (!count(getStructureChildData($GLOBALS['content']['cat_id']))) | ||
+ | echo 'No Sub-level!'; | ||
+ | else | ||
+ | echo 'Sub-level available!'; | ||
+ | |||
+ | </code> | ||
+ | |||
+ | \\ |