Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • perfect! that did the trick, thank you so much!

    oh wow, I didnt expect such a quick response - im flabbergasted, thank you so much!

    if I insert an &nbsp it looks well organized already (so I could live with that), but if I insert a dash it still gets repeated 4 times (but doesnt stack anymore) can you tell me whats the reason for that?

    Hope somebody can help me out here – I tried tbird12’s solution & it works fine! (thank you very much!)

    What I wanted to do is to indent the sub-taxonomies down the list, like:

    tax_1
    – sub_1
    – sub_2
    tax2
    – sub_3

    (and btw: that should be a feature!)
    so I started playing around with it. this almost did the job:

    function sort_terms_hierarchy(Array &$terms) {
    	$result = array();
    	$parent = 0;
    	$depth = 0;
    	$i = 0;
    	do {
    		$temp = array();
    		foreach($terms as $j => $term) {
    			if ($term->parent == $parent) {
    				$term->depth = $depth;
    				$term->name = str_repeat(' ',$depth).$term->name.' ('.$term->count.')';
    				array_push($temp, $term);
    				unset($terms[$j]);
    			}
    			elseif ($term->parent != $parent) {
    				$term->name = ('- ').$term->name;
    			}
    		}
    		array_splice($result, $i, 0, $temp);
    		$parent = $result[$i]->term_id;
    		$depth = $result[$i]->depth + 1;
    	} while ($i++ < count($result));
    	$terms = $result;
    }

    … the only flaw is that with every taxonomy down the list, it will add 4 more – – – – to every sub-tax;
    (moving the array_push and the unset underneath my elseif will lead to the desired layout, but the items will be sorted alphabetically again)

    – what am I missing? any suggestion is appreciated!

    and yes, my php is very basic indeed ??

Viewing 3 replies - 1 through 3 (of 3 total)