Thank you @TW_Tones for the suggestion. It makes sense to have a returned tiddler order that itself has a use. I had a quick look at the code, and I think one only needs to change
$tw.utils.pushTop(results,intermediate);
intermediate.forEach(function(title) {
gettagsrecursively(title,results,options);
});
to
intermediate.forEach(function(title) {
$tw.utils.pushTop(results,title);
gettagsrecursively(title,results,options);
});
so that the hierarchy is “logged” into the results array as it’s traversed. The traversal already happens “depth first”.
One thing to consider – before I test and change this – is that duplicates are removed. So, when you have tiddlers with multiple parent tags within the hierarchy, they will only show up once when they are encountered first.
Also, how do you plan to make use of this? The returned tiddlers carry no information about where within the hierarchy they are located or at what level, regardless of their ordering, so you would have to have some additional machinery in place to figure this out, which will probably kill the performance gains you get from using taggingtree[]
.
On the other hand, @EricShulman’s solution will let you easily and selectively perform additional operations while traversing the hierarchy, without necessarily operating on a whole family of tiddlers at once.
Have a nice day
Yaisog