Hi David,
Passing the filename and Templatename is pretty simple:
[[!SnippetName? &fileName=`somefilename` &xmlTpl=`someTemplatename`]]
Then in the snippet:
$fileName = $modx->getOption('fileName', $scriptProperties, '');
if (empty($fileName)) {
return 'No Filename');
}
$templateName = $modx->getOption('xmlTpl', $scriptProperties, '');
if (empty($templateName)) {
return 'No Templatename');
}
Using a Tpl chunk for the output is also fairly simple, though setting the fields from the XML results may be tedious, depending on how big the XML file is.
Basically, you create a chunk (lets call it xmlTpl) using placeholders for each entry:
<h4>Country: [[+country]]</h4>
<h3>[[+headline]]</h3>
Then create an array of fields with the same names from the XML results:
$fields = array(
'country' => $xml->DigestName->Category,
'headline' => $xml->DigestName->Headline,
// etc
);
Be careful to use => rather than = in the array and end each line with a comma, not a semicolon.
Once that's done, you just add this line:
return $modx->getChunk('xmlTpl', $fields);
There is a way to generate the fields array automatically from the XML result (assuming that the fields are in one dimension -- i.e., not nested), but if the XML file is short and doesn't change often, it may not be worth the trouble.