I’m trying to come up with some uses for this. I can see that it would be useful for picking an image to display from a directory of images. I also see that it can provide a link to a file. If it’s an HTML file, it will display (with no template). A .PDF file will launch Adobe Reader. Is there any way to use it to provide a download option for the selected file?
Any other uses for this?
-
☆ A M B ☆
- 24,524 Posts
Does this help?
http://sottwell.com/tv-bindings.html
I much prefer to use a snippet, and any page-specific variables are handled by using a parameter in the snippet call, and using a TV for the parameter value for that document. The only @binding I ever use is the @INHERIT, which I use a lot.
Understanding the @bindings are actually pretty easy; they’re all in one switch statement in the manager/includes/tmplvars.commands.inc.php file.
case 'DIRECTORY' :
$files = array ();
$path = $modx->config['base_path'] . $param;
if (substr($path, -1, 1) != '/') {
$path .= '/';
}
if (!is_dir($path)) {
die($path);
break;
}
$dir = dir($path);
while (($file = $dir->read()) !== false) {
if (substr($file, 0, 1) != '.') {
$files[] = "{$file}=={$param}{$file}";
}
}
asort($files);
$output = implode('||', $files);
break;
-
☆ A M B ☆
- 2,475 Posts
Thanks Susan, that is a helpful page.
Looking at the code, it’s fairly easy to see what the bindings do... but casual users aren’t going to be looking at that. "Casual users"... why did that phrase pop into my head?
Thanks Susan, I had found that code (and your @ bindings page). I just couldn’t think of much to do with this @ binding (or @SELECT, for that matter). I would use a snippet, but I’m writing a book and one of the headings is @ bindings so I can’t just say "use a snippet."
-
☆ A M B ☆
- 24,524 Posts
Why not? The TV is there, but it’s like the legacy global meta tags system; if it’s not a whole lot of use, why use it and clutter up the document editing form if it has no advantage?