---
title: "Working with collections"
manual: "TYPO3 Explained"
version: "11.5"
permalink: "https://docs.typo3.org/permalink/t3coreapi:fal-using-fal-examples-collections@11.5"
source: "ApiOverview/Fal/UsingFal/ExamplesCollection.rst"
rendered: "2026-10-21T15:30:00+00:00"
---

> [!WARNING]
> **Attention**
>
> TYPO3 v11 has reached end-of-life as of October 31th 2024 and
> is no longer being maintained. Use the version switcher on the top
> left of this page to select documentation for a supported version of TYPO3.
>
> Need more time before upgrading?
> You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here:
> [TYPO3 ELTS](https://typo3.com/services/extended-support-elts).

# 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@11.5).

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

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension;

use TYPO3\CMS\Core\Resource\ResourceFactory;

final class CollectionExample
{
    private ResourceFactory $resourceFactory;

    public function __construct(ResourceFactory $resourceFactory) {
        $this->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@11.5) 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@11.5) view, you could do the following:

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

```
