It looks as if my enthusiasm for xhtml URLs was over the top. I’ve experimented with switching friendly URLs off (this also meant I had to put an ID rather than a page alias into the action attribute of my preview form), and found the following works in the inc file:
if (isset($fields['preview'])) {
$landing .= ($modx->config['friendly_urls'] == 1) ? '?' : '&';
$landing .= 'template=preview&docid=' . $doc->Get('id');
} else {
$landing .= (!empty($docId)) ? '#' . $prefix . $docId : '';
}
As before, the relevant part of the config file looks like this:
if ($_REQUEST['template'] !== 'preview') {
$tpl = 'newsItem.tpl';
} else {
$documents = $_REQUEST['docid'];
$showPublishedOnly = 0;
$tpl = 'news.preview.tpl';
}
I’m not sure what’s going on with the ampersands. When I have friendly URLs on, they seem to come out like
/news.html?template=preview&docid=35 regardless of whether I use ’&’ or ’&’, and, more curious, regardless of the setting in Tools > Configuration for "XHTML URLs".
If friendly URLs are off, the URL always comes out with
& if that’s what is in $landing, again regardless of the configuration setting. So let’s leave it to MODx to keep XHTML happy on this point, and put a plain old ampersand in $landing.
The issue of using question mark or ampersand has nothing to do with PHP, the URL has to conform to the standard way of providing data to any kind of program that resides at the relevant address. See
Wikipedia for more information. (I’m pretty sure every mental asylum has at least one person

sitting in a corner muttering to themself about ampersands.)

KP