How to filter collections by group name

I need help on how to filter collections by there group name.

Thank you

Collections are defined as php files inside storage/collections, so you can’t filter them directly with a database request. Use some simple php instead:

$searchTerm = 'groupname';

$filteredCollections = [];

$allCollections = $app->module('collections')->collections();

$allCollectionsWithUserAccess = $app->module('collections')->getCollectionsInGroup();

foreach($allCollectionsWithUserAccess as $c) {
    if (isset($c['group']) && $c['group'] == $searchTerm) {
        $filteredCollections[] = $c;
    }
}

See also:

Hi,

By any chance can one get collections of cockpit via there groupname?

Thank you

And please don’t double post your questions. I moved your old thread, because I answered the newer one already.