This is great, but I've encountered a possible bug, unless I'm doing something wrong.
As a test I used it to create a simple site map using a recursive function -- besides the page title, I also wanted a 'headline' field, so it seemed a good candidate for an autojoin test.
When I ran it, however, there were some unexpected results (missing child pages and missing page names in urls) with the autojoin feature.
Here is the plaintext output from my tests (correct version first, then the incorrect version):
Notes:
C = hasChildren / numChildren (same result)
$p = current Page object being traversed
In both cases, the sort order is default (manual sort in the backend).
All pages use the same template (so definitely contain the fields being autojoined).
In all cases, both the 'title' and 'headline' fields were present in the output, so I omitted them below.
This is the recursive function I'm using:
// Called with: siteMap($pages->get(1))
function siteMap(Page $p) {
$str = '';
$children = $p->children('join=title|headline'); // with autojoin
// $children = $p->children(); // without autojoin
foreach ($children as $c) {
$str .= $c->id . " " . $c->hasChildren() . " " . $p->id . " " . $c->url . "\n";
if ($c->hasChildren()) {
$str .= siteMap($c);
}
}
return $str;
}
The following methods all produce the same incorrect results:
$p->children('join=title|headline');
wire('pages')->find('parent='.$p.', join=title|headline');
wire('pages')->findJoin('parent='.$p, 'title,headline');
wire('pages')->findJoin('parent='.$p, ['title','headline']);
Furthermore, it made no difference if I used "field" or "join" as the keyword in the selector.
ProcessWire 3.0.172 (DEV)
PHP 7.2.0
MySQL 5.7.19