简体   繁体   中英

TYPO3 Neos - Access Media Management files through TypoScript?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM