Thanks for the advice. I did not realise Wayfinder could output Template Variables.
I am actually using it in a bit of a hacky way. I wanted to output an array of all the documents (with TVs and in the tree order) so i can use it in my own custom PHP script. I tried doing it with SQL but gave up pretty quick after a join too many! And I could not find any examples of how to do this using the API (which i am sure is much cleaner and the recommended method).
For anyone that might find it useful here is the snippet code (slightly modified so needs testing!)
//Get an array of all documents and TVs in the tree order
$documents = $modx->runSnippet("Wayfinder", array(
"startId" =>1,
"level" =>5,
"removeNewLines" =>"true",
"outerTpl" =>"@CODE:[+wf.wrapper+]",
"rowTpl" =>"@CODE:[+wf.docid+] ,[+wf.subitemcount+] ,[+wf.title+] ,[+myCustomTvs+] ,[+myOtherCustomTvs+] ,[+ohMyAnotherCustomTvs+] ,[+wf.wrapper+]"
));
//remove the extra item that gets added to end of array
$d = substr($documents, 0, -1);
//Explode values from wayfinder seperated by comma
$docs = (explode(" ,",$d));
//Create an arrary for each doc
$docArray = array_chunk($docs,6);
print_r ($docArray);
Wayfinder seems very similar to Ditto. Which one is more optimal (speed wise) to use? I know Ditto does a lot more, but I noticed the number of DB queries was slightly less when using Wayfinder than Ditto (at least for what i was trying to do).