Ok, new version. It’s not as bad as I thought. I think this will do exactly what you want.
Create a TV for each directory you want to show (use duplicate). Use the name of the directory for the Name and the Caption of the TV (I’m not sure if you can use backslashes or not).
Put this in the Input Option Values (correcting the Dir for each one). Needs a trailing backslash but no leading backslash):
Assets TV
@EVAL return($modx->runSnippet('GetDir',array('Dir'=>'assets/')));
Assets-Snippets TV
@EVAL return($modx->runSnippet('GetDir',array('Dir'=>'assets/snippets/')));
Here’s the new GetDir snippet:
<?php
$output = '';
$first = true;
$base = $modx->config['base_url'];
$url_base = $base . $Dir;
$dir = $modx->config['base_path'] . $Dir;
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && (!is_dir($dir.$file)) ) {
if (!$first) {
$output .= '||';
};
$output .= $file. '==' . '<li><a href="'. $url_base . $file . '">' . $file . '</a></li>';
if ($first == true) $first = false;
}
}
closedir($handle);
return $output;
}
?>
In the document, you’ll have tags for all the TVs:
<h3>Assets</h3>
[*Assets*]
<h3>Assets-Snippets</h3>
[*Assets-Snippets*]
Bob’s your uncle.