<?php
$path = 'assets/images/agents/ashley-peterson/4717-linden/';
$dir_handle = @opendir($path) or die('Unable to open ' . $path);
$array = array();
while (($file = readdir($dir_handle)) !== false)
{
if ($file != '.' && $file != '..')
{
$pathinfo = pathinfo($file);
if (isset($pathinfo['extension'])) {$ext = strtolower($pathinfo['extension']);} else {$ext = '';}
if ($ext == 'jpg' || $ext == 'jpeg') {$array[] = $file;}
}
}
if ($array)
{
sort($array); // Use rsort for Z-A order
foreach ($array as $value)
{
echo '<img src="' . $path . $value . '" alt="" ?>' . "\n";
}
}$path = 'assets/images/agents/ashley-peterson/4717-linden/';
<?php $path = isset($path) ? $path : 'assets/images/replace-with-default-path/';
Your syntax is a little off. Remember to always use backticks (`), and use ¶meter for your snippet parameters. Try this for the snippet call:
[[!getdirectoryimages? &path=`[[*directoryTV ]]` ]]
Remove the following from your snippet code and it should work.
$path = 'assets/images/agents/ashley-peterson/4717-linden/';
If you want to define a default path, add this to the beginning of your snippet:
<?php $path = isset($path) ? $path : 'assets/images/replace-with-default-path/';
(checks for ’path’ in your snippet call; returns default if not set)
$dir_handle = @opendir($modx->getOption('assets_url') . $path) or die('Unable to open ' . $path);
The only thing I see is that the path in your snippet ends with a slash and it looks like your TV doesn’t.
You could also try using a full URL and changing the TV to: images/agents/ashley-peterson/4717-linden/
$dir_handle = @opendir($modx->getOption('assets_url') . $path) or die('Unable to open ' . $path);
If that’s not it, paste your current snippet code and your current tag into a message.
<?php
$dir_handle = @opendir($modx->getOption('assets_url') . $path) or die('Unable to open ' . $path);
$array = array();
while (($file = readdir($dir_handle)) !== false)
{
if ($file != '.' && $file != '..')
{
$pathinfo = pathinfo($file);
if (isset($pathinfo['extension'])) {$ext = strtolower($pathinfo['extension']);} else {$ext = '';}
if ($ext == 'jpg' || $ext == 'jpeg') {$array[] = $file;}
}
}
if ($array)
{
sort($array); // Use rsort for Z-A order
foreach ($array as $value)
{
echo '<img src="' . $path . $value . '" alt="" ?>' . "\n";
}
}
echo '<img src="' . $path . $value . " alt="" />' . "\n";
<?php
$dir_handle = @opendir($path) or die('Unable to open ' . $path);
$array = array();
while (($file = readdir($dir_handle)) !== false)
{
if ($file != '.' && $file != '..')
{
$pathinfo = pathinfo($file);
if (isset($pathinfo['extension'])) {$ext = strtolower($pathinfo['extension']);} else {$ext = '';}
if ($ext == 'jpg' || $ext == 'jpeg') {$array[] = $file;}
}
}
if ($array)
{
sort($array); // Use rsort for Z-A order
foreach ($array as $value)
{
echo '<img src="' . $path . $value . '" alt="" />' . "\n";
}
}