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.
Uri.resource ViewHelper <f:uri.resource>
A ViewHelper for creating URIs to resources.
Examples
Best practice with EXT: syntax
<link href="{f:uri.resource(path:'EXT:indexed_search/Resources/Public/Css/Stylesheet.css')}" rel="stylesheet" />
Output:
<link href="typo3/sysext/indexed_search/Resources/Public/Css/Stylesheet.css" rel="stylesheet" />
Preferred syntax that works in both extbase and non-extbase context.
Defaults
<link href="{f:uri.resource(path:'Css/Stylesheet.css')}" rel="stylesheet" />
Output:
<link href="typo3conf/ext/example_extension/Resources/Public/Css/Stylesheet.css" rel="stylesheet" />
Works only in extbase context since it uses the extbase request to find current extension, magically adds 'Resources/Public' to path.
With extension name
<link href="{f:uri.resource(path:'Css/Stylesheet.css', extensionName: 'AnotherExtension')}" rel="stylesheet" />
Output:
<link href="typo3conf/ext/another_extension/Resources/Public/Css/Stylesheet.css" rel="stylesheet" />
Magically adds 'Resources/Public' to path.
Source code
Go to the source code of this ViewHelper: ResourceViewHelper.php (GitHub).
Arguments
The following arguments are available for <f:
:
path
-
- Type
- string
- Required
true
The path and filename of the resource (relative to Public resource directory of the extension).
extensionName
-
- Type
- string
Target extension name. If not set, the current extension name will be used
absolute
-
- Type
- boolean
If set, an absolute URI is rendered