Grouping Files with File Sets

Was this information useful?
Thank you for your feedback.

File Sets are a useful way to organize files in Concrete CMS. A single file can be in multiple File Sets. The file manager interface provides ways to filter by file sets, and developers can work with them through code easily as well. Adding a file to a file set programmatically is easy:

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

Removing a file from a set is similar simple:


Creating a File Set Programmatically

Sometimes you want to create a file set programmatically. For example, you're creating a custom package and you want all files of a certain type added to a particular file set. Creating a file set programmatically is easy:

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

The File Set object has a few more API methods that might be useful.


These are just a few examples of what can be done with the Concrete File API. Get more from the Page API docs:

File Set API Reference