neoscmstyposcript2

Link to an asset with TypoScript


In Fluid, it is easy to create an URI pointing to an asset by using the ViewHelper provided:

{f:uri.resource(resource: asset.resource)}

But how can I create a link or URI from TypoScript?


Solution

  • In TypoScript, any HTML tag can be created by using the TYPO3.TypoScript:Tag object. The asset is referenced with a Eel expression. In the example below the asset identifier is taken from the asset property, but it would also be possible to use the UUID of the resource.

    To create the URI, the convertUris processor is then applied.

    myLinkTag = TYPO3.TypoScript:Tag {
      tagName = 'a'
      attributes.href = ${'asset://' + node.properties.asset.resource}
      attributes.href.@process.convertUris = TYPO3.Neos:ConvertUris
      content = 'My link text'
    }