Get stacks by folder

Permalink 1 user found helpful
I know I can get a specific stack by handle like this:
$stack = Stack::getByName('STACK NAME');


But is there a way to get all stacks that belong to a folder?

 
hutman replied on at Permalink Best Answer Reply
hutman
It looks like the Dashboard does this

use Concrete\Core\Support\Facade\StackFolder;
use Concrete\Core\Page\Stack\StackList;
$folder = StackFolder::getByID($stackFolderID);
if (is_object($folder)) {
    $list= new StackList();
    $list->filterByFolder($folder);
    $list->setFoldersFirst(true);
    $list->setSiteTreeObject($this->getSite()->getSiteTreeObject());
    $stacks = $list->getResults();
}
Kiesel replied on at Permalink Reply
Thank you! I did meanwhile just a manual search pattern for the parent id, which worked, but I'll try this method on the next project.