あなたのフォルダ構造を見事に深みを持たないことを確かめてください。何百ものレベルの数百のフォルダを通過したくない場合があります。
ここでコード
<?php
use Concrete\Core\Tree\Node\Type\FileFolder;
use Concrete\Core\File\FolderItemList;
// First grab the folder object
$folder = FileFolder::getNodeByName('Testing Folder');
if (is_object($folder)) {
$files = [];
// if we have a folder we need to grab everything inside and then
// recursively go through the folder's content
// if what we get is a file we list it
// otherwise if it's another folder we go through it as well
$walk = function ($folder) use (&$files, &$walk) {
$list = new FolderItemList();
$list->filterByParentFolder($folder);
$list->sortByNodeName();
$nodes = $list->getResults();
foreach ($nodes as $node) {
if ($node->getTreeNodeTypeHandle() === 'file'){
$files[] = $node->getTreeNodeFileObject();
} elseif ($node->getTreeNodeTypeHandle() === 'file_folder'){
$walk($node);
}
}
};
$walk($folder);
// we are done going through all the folders, we now have our file nodes
foreach ($files as $file) {
echo sprintf('%sfile name is %s and URL is %s%s', '<p>', $file->getTitle(), $file->getURL(), '</p>');
}
}
です