---
title: "Working with collections"
manual: "TYPO3 Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3coreapi:fal-using-fal-examples-collections@main"
source: "ApiOverview/Fal/UsingFal/ExamplesCollection.rst"
rendered: "2026-09-26T10:15:30+00:00"
---

# Working with collections {#fal-using-fal-examples-collections}

The `\TYPO3\CMS\Core\Resource\ResourceFactory` class
provides a convenience method to retrieve a
[File Collection](https://docs.typo3.org/permalink/t3coreapi:fal-architecture-components-collections@main).

**EXT:my_extension/Classes/CollectionExample.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension;

use TYPO3\CMS\Core\Resource\ResourceFactory;

final class CollectionExample
{
  public function __construct(
    private readonly ResourceFactory $resourceFactory,
  ) {}

  public function doSomething(): void
  {
    // Get collection with uid 1
    $collection = $this->resourceFactory->getCollectionObject(1);

    // Load the contents of the collection
    $collection->loadContents();
  }
}

```

In this example, we retrieve and load the content from the
[File Collection](https://docs.typo3.org/permalink/t3coreapi:collections-files@main) with a uid of "1". Any collection
implements the `\Iterator` interface, which means that a collection
can be looped over (once its content has been loaded). Thus,
if the above code passed the `$collection` variable to
a [Fluid](https://docs.typo3.org/permalink/t3coreapi:fluid@main) view, you could do the following:

**EXT:my_extension/Resources/Private/Templates/SomeTemplate.fluid.html**

```html
<ul>
  <f:for each="{collection}" as="file">
    <li>{file.title}</li>
  </f:for>
</ul>

```
