TYPO3 Neos - Access Media Management files through TypoScript?

237 views Asked by At

is it possible to access files uploaded in the media management using typoscript in TYPO3 Neos? I'm trying to create a site listing all pdfs uploaded by the editors, but I couldn't figure out a way to access these pdfs via typoscript.

1

There are 1 answers

1
Christopher On BEST ANSWER

It is currently (state of Neos 1.2 beta) not possible to gather a list of assets with the built-in TypoScript objects / Eel helpers. There are two ways to implement your requirement:

  1. Create a plugin that renders the list of PDFs
  2. Create a new TypoScript object or Eel helper to fetch a list of assets

A plugin can be created following the guide on the Neos documentation. If you want to render the list via TypoScript, it's easy to create such a TypoScript object in your own site package:

use TYPO3\Flow\Annotations as Flow;

class AssetCollection extends \TYPO3\TypoScript\TypoScriptObjects\AbstractTypoScriptObject {

    /**
     * @Flow\Inject
     * @var \TYPO3\Media\Domain\Repository\AssetRepository
     */
    protected $assetRepository;

    public function evaluate() {
        return $this->assetRepository->findAll();
    }

}

And then use that new object in TypoScript:

prototype(TYPO3.NeosDemoTypo3Org:AssetCollection) {
    @class = 'TYPO3\\NeosDemoTypo3Org\\TypoScriptObjects\\AssetCollection'
}

page.body.assets = TYPO3.NeosDemoTypo3Org:AssetCollection