Ted Striker
Forum Replies Created
-
Forum: Plugins
In reply to: [Facetious] Displaying taxonomy filters hierarchicallyperfect! that did the trick, thank you so much!
Forum: Plugins
In reply to: [Facetious] Displaying taxonomy filters hierarchicallyoh wow, I didn
t expect such a quick response - i
m flabbergasted, thank you so much!if I insert an   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?
Forum: Plugins
In reply to: [Facetious] Displaying taxonomy filters hierarchicallyHope 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 thearray_push
and theunset
underneath myelseif
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 ??