Organizing Files


Let us know by posting here.

Grouping Files with File Sets

File Sets in Concrete CMS allow for efficient file organization, enabling a file to belong to multiple sets. The file manager interface facilitates file set filtering, and they are easily manageable via code. To add a file to a file set:

$file = \Concrete\Core\File\File::getByID(1);
$set = \Concrete\Core\File\Set\Set::getByName('My File Set');

To remove a file from a set:


Creating a File Set Programmatically

For automatic file set creation, like in custom packages, you can use:

$set = \Concrete\Core\File\Set\Set::createAndGetSet(
    'My File Set', 

FileList Object in Concrete CMS

The Concrete\Core\File\FileList object in Concrete CMS helps developers query files using various criteria, considering permissions and underlying complex table structures.

$list = new \Concrete\Core\File\FileList();
$files = $list->getResults(); // Array of \Concrete\Core\File\File objects

Basic Filtering Examples

Filter by File Type using constants from \Concrete\Core\File\Type\Type:

  • \Concrete\Core\File\Type\Type::T_IMAGE = 1 (and other type constants)

Filter by Extension:


Filter By Keywords:


Filter By File Set:

$set = \Concrete\Core\File\Set\Set::getByName('My File Set');

Include Files in No Sets:


Filter By File Size (in KB):

$list->filterBySize(1024, 2048); // 1MB to 2MB

Filter by Attribute

$list->filterByAttribute('width', 200, '>='); // Width 200 or greater


Sort by filename ascending:


Sort by File Set Display Order:



Ignore permissions:


Custom Queries

Utilize the Doctrine DBAL QueryBuilder through the FileList object:

$query = $list->getQueryObject();


Get paginated results:

$pagination = $list->getPagination();
// Use methods like getTotalResults(), getTotalPages(), hasNexPage(), hasPreviousPage()

Rendering Pagination

Render pagination HTML (Bootstrap 3, Basic Pagination, etc.):

print $pagination->renderDefaultView();