### Debug Output Example for Objects Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Debug.rst This is an example of the plain text output when debugging an object instance. It shows the path, value type, and lists accessible properties with their types. ```text Path: {domainObject} Value type: object Accessible properties on {domainObject}: {form.uid} (integer) {form.title} (string) ``` -------------------------------- ### Asset Management Example Source: https://context7.com/fluidtypo3/vhs/llms.txt Declaratively register CSS and JavaScript from partials and layouts using asset ViewHelpers. Assets are collected once and included exactly once. ```fluid v:asset.script v:asset.style ``` -------------------------------- ### Install VHS Extension with Composer Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/Installation/Index.rst Use this command to add the VHS extension to your TYPO3 project via Composer. Ensure you are in your TYPO3 installation directory. ```bash composer require fluidtypo3/vhs ``` -------------------------------- ### Page and Navigation Rendering Example Source: https://context7.com/fluidtypo3/vhs/llms.txt Build SEO-friendly page structures with dynamic titles, meta tags, and accessible navigation using page and menu ViewHelpers. ```fluid v:page.info v:page.breadcrumb v:menu.* v:page.header.* ``` -------------------------------- ### resource.language ViewHelper Usage Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Resource/Language.rst Examples of how to use the resource.language ViewHelper to fetch language labels. ```APIDOC ## resource.language ViewHelper ### Description Reads a certain language file with returning not just one single label, but all the translated labels. ### Arguments #### as - **as** (string) - Optional - Template variable name to assign; if not specified the ViewHelper returns the variable instead. #### extensionName - **extensionName** (string) - Optional - Name of the extension #### path - **path** (string) - Optional - Absolute or relative path to the locallang file. Defaults to 'locallang.xlf'. #### languageKey - **languageKey** (string) - Optional - Key for getting translation of a different than current initialized language ### Examples #### Force getting labels in a specific language ```html ``` #### Getting labels of the current language ```html ``` ``` -------------------------------- ### security.allow ViewHelper Usage Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Security/Allow.rst This example demonstrates how to use the security.allow ViewHelper with f:then and f:else to conditionally display content based on user authentication. ```APIDOC ## vhs:security.allow ### Description Allows access to the child content based on given arguments. This ViewHelper is condition-based and supports `f:then` and `f:else` child nodes. ### Arguments #### then - **mixed** - Optional - Value to be returned if the condition is met. #### else - **mixed** - Optional - Value to be returned if the condition is not met. #### anyFrontendUser - **boolean** - Optional - If TRUE, allows any FrontendUser unless other arguments disallow each specific FrontendUser. #### anyFrontendUserGroup - **boolean** - Optional - If TRUE, allows any FrontendUserGroup unless other arguments disallow each specific FrontendUserGroup. #### frontendUser - **mixed** - Optional - The FrontendUser to allow/deny. #### frontendUsers - **mixed** - Optional - The FrontendUsers ObjectStorage to allow/deny. #### frontendUserGroup - **mixed** - Optional - The FrontendUserGroup to allow/deny. #### frontendUserGroups - **mixed** - Optional - The FrontendUserGroups ObjectStorage to allow/deny. #### anyBackendUser - **boolean** - Optional - If TRUE, allows any backend user unless other arguments disallow each specific backend user. #### backendUser - **integer** - Optional - The uid of a backend user to allow/deny. #### backendUsers - **mixed** - Optional - The backend users list to allow/deny. If string, CSV of uids assumed, if array, array of uids assumed. #### backendUserGroup - **integer** - Optional - The uid of the backend user group to allow/deny. #### backendUserGroups - **mixed** - Optional - The backend user groups list to allow/deny. If string, CSV of uids is assumed, if array, array of uids is assumed. #### admin - **boolean** - Optional - If TRUE, a backend user which is also an admin is required. #### evaluationType - **string** - Optional - Specify AND or OR (case sensitive) to determine how arguments must be processed. Default is AND, requiring all arguments to be satisfied if used. ### Example ```html ``` ``` -------------------------------- ### Tag Call Examples Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Call.rst The tag syntax is useful for quickly outputting simple values or when the object itself is the primary content being passed to the ViewHelper. ```fluid ``` ```fluid {object} ``` -------------------------------- ### Get first names of several users Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Iterator/Extract.rst This example demonstrates extracting 'firstname' from a list of frontend users and joining them with a comma and space. It shows two syntactical variations for achieving the same result. ```html

Welcome {frontendUsers -> v:iterator.extract(key: 'firstname') -> v:iterator.implode(glue: ', ')}

``` -------------------------------- ### Simple Backend Context Check Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Condition/Context/IsBackend.rst Use this ViewHelper to render its content only when the current context is the backend. No additional setup is required. ```html Hooray for BE contexts! ``` -------------------------------- ### Basic asset.prefetch Usage Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Asset/Prefetch.rst Use this ViewHelper to instruct the browser to start prefetching DNS records for the listed domains. Prefetching begins as soon as the browser encounters the tag. ```html ``` -------------------------------- ### Inline Call Example Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Call.rst Use this inline syntax when the object is already available and you need to call a method on it, for instance, as an argument to another ViewHelper like f:for. ```fluid {object -> v:call(method: 'toArray')} ``` -------------------------------- ### doktypes Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Page/Menu/Directory.rst DEPRECATED: Use typical doktypes for starting points like shortcuts. ```APIDOC ## doktypes ### Description DEPRECATED: Please use typical doktypes for starting points like shortcuts. ### DataType mixed ### Required false ``` -------------------------------- ### media.picture ViewHelper Usage Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Media/Picture.rst This example demonstrates how to use the `` ViewHelper to render a `` element. It includes a main image source and multiple `` elements for different media breakpoints, allowing the browser to select the most appropriate image. ```APIDOC ## `` ViewHelper ### Description Renders a picture element with different images/sources for specific media breakpoints. ### Arguments * **src** (mixed) - Required - Path to the image or FileReference. * **alt** (string) - Required - Text for the alt attribute. * **loading** (string) - Optional - Native lazy-loading for images. Can be "lazy", "eager" or "auto". * **title** (string) - Optional - Text for the title attribute. * **class** (string) - Optional - CSS class(es) to set. * **additionalAttributes** (mixed) - Optional - Additional tag attributes. They will be added directly to the resulting HTML tag. * **data** (mixed) - Optional - Additional data-* attributes. They will each be added with a "data-" prefix. * **aria** (mixed) - Optional - Additional aria-* attributes. They will each be added with a "aria-" prefix. * **treatIdAsReference** (boolean) - Optional - When TRUE treat given src argument as sys_file_reference record. ### Example ```html ``` ### Browser Support To have the widest Browser-Support you should consider using a polyfill like: http://scottjehl.github.io/picturefill ``` -------------------------------- ### Data Transformation Pipeline Example Source: https://context7.com/fluidtypo3/vhs/llms.txt Process and display arrays, collections, and strings entirely within Fluid templates using chained iterator and format ViewHelpers. ```fluid {items -> v:iterator.sort(...) -> v:iterator.filter(...)} ``` -------------------------------- ### Extract values from an array by key Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Iterator/Extract.rst This example shows how to extract 'sword' values from an array of search results and join them with a space. ```html ``` -------------------------------- ### For Loop with Step Value Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/Classes/ViewHelpers/Iterator/ForViewHelper/README.md This example demonstrates iterating with a specific step value to display odd numbers up to 1000. Ensure the step value is compatible with the from and to arguments to avoid runtime exceptions. ```html {i.index} ``` -------------------------------- ### asset.prefetch ViewHelper Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Asset/Prefetch.rst Enables DNS prefetching by inserting `` tags. This ViewHelper instructs the browser to start prefetching DNS records for domains listed in the `domains` attribute. ```APIDOC ## asset.prefetch ViewHelper `` ### Description Enables the special `` tag which instructs the browser to start prefetching DNS records for every domain listed in the `domains` attribute of this ViewHelper. Prefetching starts as soon as the browser becomes aware of the tag. To optimize further, you may wish to control the output buffer's size to deliver your site HTML in chunks, the first chunk being the one containing this ViewHelper. Note that the web server daemon may send headers which prevent this prefetching and that these headers can be added in many ways. If prefetching does not work, you will need to inspect the HTTP headers returned from the actual environment. Or you may prefer to simply add `force="TRUE"` to this tag - but beware that this will affect the entire document's behaviour, not just for this particular set of domain prefetches. Once force-enabled this setting cannot be disabled (unless done so by manually adding an additional meta header tag as examplified by the `build()` method. ### Example Usage ```html ``` ### Arguments #### domains * **Type**: `string` * **Required**: `true` * **Description**: Comma-separated list of domains to prefetch. #### content * **Type**: `string` * **Required**: `false` * **Description**: Content to insert in header/footer. #### path * **Type**: `string` * **Required**: `false` * **Description**: If not using tag content, specify path to file here. #### external * **Type**: `boolean` * **Required**: `false` * **Description**: If TRUE and standalone, includes the file as raw URL. If TRUE and not standalone then downloads the file and merges it when building Assets. #### name * **Type**: `string` * **Required**: `false` * **Description**: Optional name of the content. If multiple occurrences of the same name happens, behavior is defined by argument "overwrite". #### overwrite * **Type**: `boolean` * **Default**: `true` * **Required**: `false` * **Description**: If set to FALSE and a relocated string with "name" already exists, does not overwrite the existing relocated string. Default behavior is to overwrite. #### dependencies * **Type**: `string` * **Required**: `false` * **Description**: CSV list of other named assets upon which this asset depends. When included, this asset will always load after its dependencies. #### group * **Type**: `string` * **Default**: `'fluid'` * **Required**: `false` * **Description**: Optional name of a logical group (created dynamically just by using the name) to which this particular asset belongs. #### debug * **Type**: `boolean` * **Required**: `false` * **Description**: If TRUE, outputs information about this ViewHelper when the tag is used. Two master debug switches exist in TypoScript; see documentation about Page / Asset ViewHelper. #### standalone * **Type**: `boolean` * **Required**: `false` * **Description**: If TRUE, excludes this Asset from any concatenation which may be applied. #### rewrite * **Type**: `boolean` * **Default**: `true` * **Required**: `false` * **Description**: If FALSE, this Asset will be included as is without any processing of contained urls. #### fluid * **Type**: `boolean` * **Required**: `false` * **Description**: If TRUE, renders this (standalone or external) Asset as if it were a Fluid template, passing along values of the "variables" attribute or every available template variable if "variables" not specified. #### variables * **Type**: `mixed` * **Required**: `false` * **Description**: An optional array of arguments which you use inside the Asset, be it standalone or inline. Use this argument to ensure your Asset filenames are only reused when all variables used in the Asset are the same. #### movable * **Type**: `boolean` * **Default**: `true` * **Required**: `false` * **Description**: If TRUE, allows this Asset to be included in the document footer rather than the header. Should never be allowed for CSS. ``` -------------------------------- ### Chaining Math ViewHelpers Source: https://github.com/fluidtypo3/vhs/wiki/Base-Classes:-Math-Based-ViewHelper Demonstrates how to chain multiple math-based ViewHelpers for sequential calculations. The output type typically matches the initial input type, allowing for fluid data transformation. ```xml Size: {bytes->v:math.division(b: 1024)->v:math.round()->f:format.number()} KB ``` -------------------------------- ### Get Current UNIX Timestamp and Add One Hour Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/System/Timestamp.rst Use this ViewHelper to get the current UNIX timestamp and combine it with the Math ViewHelpers to perform calculations, such as adding an hour to a DateTime object before formatting it. ```html {dateTime.timestamp -> v:math.sum(b: 3600)} ``` -------------------------------- ### Basic media.picture Usage Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Media/Picture.rst Use this ViewHelper to create a responsive image element. Specify the main image source with 'src' and 'alt', and use nested tags to define alternative sources for different media queries and resolutions. ```html ``` -------------------------------- ### math.minimum ViewHelper Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Math/Minimum.rst Gets the lowest number in array $a or the lowest number of numbers $a and $b. ```APIDOC ## math.minimum ViewHelper `` ### Description Gets the lowest number in array $a or the lowest number of numbers $a and $b. ### Arguments #### a - **DataType**: mixed - **Required**: false - **Description**: First number for calculation #### b - **DataType**: mixed - **Required**: false - **Description**: Second number or Iterator/Traversable/Array for calculation #### fail - **DataType**: boolean - **Required**: false - **Description**: If TRUE, throws an Exception if argument "a" is not specified and no child content or inline argument is found. Usually okay to use a NULL value (as integer zero). ``` -------------------------------- ### format.placeholder.lipsum ViewHelper Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Format/Placeholder/Lipsum.rst The format.placeholder.lipsum ViewHelper renders Lorem Ipsum text. It accepts several arguments to customize the output, such as the source of the lipsum text, the number of paragraphs, words per paragraph, and whether to output as HTML. ```APIDOC ## VHS:format.placeholder.lipsum ### Description Renders Lorem Ipsum text according to provided arguments. ### Arguments * **lipsum** (string) - Optional - Optional, custom lipsum source * **paragraphs** (integer) - Optional - Number of paragraphs to output * **wordsPerParagraph** (integer) - Optional - Number of words per paragraph * **skew** (integer) - Optional - Amount in number of words to vary the number of words per paragraph * **html** (boolean) - Optional - If TRUE, renders output as HTML paragraph tags in the same way an RTE would * **parseFuncTSPath** (string) - Optional - If you want another parseFunc for HTML processing, enter the TS path here ``` -------------------------------- ### math.maximum ViewHelper Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Math/Maximum.rst Gets the highest number in array $a or the highest number of numbers $a and $b. ```APIDOC ## math.maximum ViewHelper `` ### Description Gets the highest number in array $a or the highest number of numbers $a and $b. ### Arguments #### a - **DataType**: mixed - **Required**: false - **Description**: First number for calculation #### b - **DataType**: mixed - **Required**: false - **Description**: Second number or Iterator/Traversable/Array for calculation #### fail - **DataType**: boolean - **Required**: false - **Description**: If TRUE, throws an Exception if argument "a" is not specified and no child content or inline argument is found. Usually okay to use a NULL value (as integer zero). ``` -------------------------------- ### iterator.keys Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Iterator/Keys.rst Gets keys from an iterator. Can be used to assign keys to a variable or return them directly. ```APIDOC ## iterator.keys ViewHelper `` ### Description Gets keys from an iterator. ### Arguments #### subject * **DataType**: mixed * **Required**: false * **Description**: Input to work on - Array/Traversable/... #### as * **DataType**: string * **Required**: false * **Description**: Template variable name to assign; if not specified the ViewHelper returns the variable instead. ``` -------------------------------- ### Return Specific Counter Value Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Format/DateRange.rst Returns the number of weeks between the start and end dates. ```fluid {v:format.dateRange(start: '2013-04-30', end: '2013-05-30', return: 'w')} ``` -------------------------------- ### format.substring ViewHelper Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Format/Substring.rst Extracts a substring from a given string. You can specify the starting position and the length of the substring. ```APIDOC ## `` ### Description Gets a substring from a string or string-compatible value. Also see the `` view helper. ### Arguments #### `content` (string, optional) Content string to substring. #### `start` (integer, optional) Positive or negative offset. #### `length` (integer, optional) Positive or negative length. ``` -------------------------------- ### l ViewHelper Usage Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/L.rst Demonstrates various ways to use the l ViewHelper for translations, including basic usage, specifying a key, and providing arguments. ```APIDOC ## l ViewHelper ### Description An extremely shortened and much more dev-friendly alternative to f:translate. Automatically outputs the name of the LLL reference if it is not found and the default value is not set, making it much easier to identify missing labels when translating. ### Usage Examples ```html some.label some.label ``` ### Arguments #### key - **key** (string) - Optional - Translation Key #### default - **default** (string) - Optional - If the given locallang key could not be found, this value is used. If this argument is not set, child nodes will be used to render the default. #### htmlEscape - **htmlEscape** (boolean) - Optional - TRUE if the result should be htmlescaped. This won't have an effect for the default value. #### arguments - **arguments** (mixed) - Optional - Arguments to be replaced in the resulting string #### extensionName - **extensionName** (string) - Optional - UpperCamelCased extension key (for example BlogExample) ``` -------------------------------- ### Create JavaScript Asset with Settings using PHP Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/Usage/Index.rst Create a JavaScript asset using the Asset::createFromSettings method, providing both a name and a path. This offers more explicit control than createFromFile. ```php \FluidTYPO3\Vhs\Asset::createFromSettings(array( 'name' => 'demo', 'path' => 'fileadmin/demo.js' )); ``` -------------------------------- ### v:format.substring Source: https://context7.com/fluidtypo3/vhs/llms.txt Extract a substring (multibyte-safe). Wraps `mb_substr`. Accepts negative `start` and `length` values. ```APIDOC ## v:format.substring ### Description Extract a substring (multibyte-safe). Wraps `mb_substr`. Accepts negative `start` and `length` values. ### Method Not applicable (ViewHelper) ### Endpoint Not applicable (ViewHelper) ### Parameters #### Attributes - **content** (string) - Optional - The string to extract from. If not provided, the content of the tag is used. - **start** (integer) - Required - The starting position (can be negative). - **length** (integer) - Optional - The length of the substring (can be negative). ### Request Example ```html {longText -> v:format.substring(start: 0, length: 10)} {longText -> v:format.substring(start: -5)} ``` ### Response - **string** (string) - The extracted substring. ``` -------------------------------- ### levels Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Menu/Browse.rst Number of levels to render. Higher values expand menu items that are active, starting from entryLevel. ```APIDOC ## levels ### Description Number of levels to render - setting this to a number higher than 1 (one) will expand menu items that are active, to a depth of $levels starting from $entryLevel. ### Aspect * DataType: integer * Default: 1 * Required: false ``` -------------------------------- ### Return Array of Counter Values Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Format/DateRange.rst Returns an array containing the number of weeks and days between the start and end dates. ```fluid {v:format.dateRange(start: '2013-04-30', end: '2013-05-30', return: {0: 'w', 1: 'd'})} ``` -------------------------------- ### Read Extension Configuration Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Variable/ExtensionConfiguration.rst Use this ViewHelper to retrieve a specific setting from an extension's configuration file. Provide the extension key and the path to the desired configuration value. ```fluid {v:variable.extensionConfiguration(extensionKey:'foo',path:'bar.baz')} ``` -------------------------------- ### Format a Date Range Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Format/DateRange.rst Formats a date range between a start and end date using configured formats and glue. ```fluid ``` -------------------------------- ### Render Template with Arguments Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Render/Template.rst Use this ViewHelper to render a template file, passing custom variables and specifying paths and format. Paths can be overridden using TypoScript settings. ```html ``` -------------------------------- ### Return DateTime Object Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Format/DateRange.rst Returns a DateTime object representing the end date, calculated by adding the interval to the start date. ```fluid {v:format.dateRange(start: '2013-04-30', intervalFormat: 'P1M', return: 'DateTime')} ``` -------------------------------- ### page.link ViewHelper Usage Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Page/Link.rst Demonstrates how to use the page.link ViewHelper with automatic and manual link text. ```APIDOC Automatic linktext: Manual linktext: linktext ``` -------------------------------- ### Count Substring Occurrences (Tag-based with arguments) Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Count/Substring.rst This example demonstrates using the tag-based syntax where both the haystack and the substring to count are provided as arguments. ```fluid ``` -------------------------------- ### Perform Math Operations with v:math.* ViewHelpers Source: https://context7.com/fluidtypo3/vhs/llms.txt Provides various mathematical operations including sum, product, modulo, power, maximum, and minimum. ```html {v:math.sum(a: price, b: tax)} {v:math.product(a: quantity, b: unitPrice)} {v:math.modulo(a: index, b: 3)} {v:math.power(a: 2, b: 8)} {v:math.maximum(a: valueA, b: valueB)} {v:math.minimum(a: valueA, b: valueB)} ``` -------------------------------- ### render.template ViewHelper Usage Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Render/Template.rst Demonstrates how to use the render.template ViewHelper to render a template file with custom variables, paths, and format. ```APIDOC ## render.template ViewHelper `` ### Description Render a template file (with arguments if desired). Supports passing variables and controlling the format. Paths can be overridden and uses the same format as TS settings a' la plugin.tx_myext.view. ### Arguments #### file - **DataType**: string - **Required**: false - **Description**: Path to template file, EXT:myext/... paths supported #### variables - **DataType**: mixed - **Required**: false - **Description**: Optional array of template variables for rendering #### paths - **DataType**: mixed - **Required**: false - **Description**: Optional array of arrays of layout and partial root paths, EXT:mypath/... paths supported #### format - **DataType**: string - **Required**: false - **Description**: Optional format of the template(s) being rendered #### onError - **DataType**: string - **Required**: false - **Description**: Optional error message to display if error occur while rendering. If NULL, lets the error Exception pass trough (and break rendering) #### graceful - **DataType**: boolean - **Required**: false - **Description**: If forced to FALSE, errors are not caught but rather "transmitted" as every other error would be ### Example ```html ``` ### Notes - A true ControllerContext is not present when rendering, which means that links generated in the template should be made always including all parameters from ExtensionName over PluginName through the usual action etc. - The Controller from EXT:foo is not involved in any way, which means that any custom variables the particular template depends on must be added manually through the "variables" argument. - Consider using Render/InlineViewHelper if you are rendering templates from the same plugin. - Consider using Render/RequestViewHelper if you require a completely isolated rendering identical to that which takes place when rendering an Extbase plugin's content object. ``` -------------------------------- ### Get labels for the current language Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Resource/Language.rst Use this snippet to retrieve labels for the currently initialized language. Only the extension name and the path to the .xlf file are required. ```html ``` -------------------------------- ### Read Extension Configuration with v:variable.extensionConfiguration Source: https://context7.com/fluidtypo3/vhs/llms.txt Accesses configuration settings for a specific extension using its key and an optional path. ```html {v:variable.extensionConfiguration(extensionKey: 'vhs', path: 'disableAssetHandling')} ``` -------------------------------- ### Get Collection by UID Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Resource/Collection.rst Use this snippet to fetch a collection using its UID and assign it to a variable for further use. Ensure the collection with the specified UID exists. ```fluid {v:resource.collection(uid:'123') -> v:var.set(name: 'someCollection')} ``` -------------------------------- ### Calculate End Date using Interval Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Format/DateRange.rst Calculates the end date by adding a specified interval to the start date. The output is the formatted date range. ```fluid ``` -------------------------------- ### Chaining String Processing with format.append Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Format/Append.rst Demonstrates chaining multiple ViewHelpers for string manipulation, including eliminating characters, appending text, and formatting as HTML. Useful for complex inline statements where direct concatenation is not feasible. ```fluid {text -> v:format.eliminate(strings: 'foo,bar') -> v:format.append(add: ' - my foo and bar are the only ones in this text.') -> f:format.html()} ``` -------------------------------- ### Basic For Loop with v:iterator.for Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/Classes/ViewHelpers/Iterator/ForViewHelper/README.md Use this ViewHelper to generate repetitive HTML content based on a numerical range. The 'iteration' argument provides access to the current loop index. ```html Cat ``` -------------------------------- ### v:asset.prefetch Source: https://context7.com/fluidtypo3/vhs/llms.txt Add a DNS-prefetch or resource-prefetch link. Inserts a `` or `` tag into the document ``. ```APIDOC ## v:asset.prefetch ### Description Add a DNS-prefetch or resource-prefetch link. Inserts a `` or `` tag into the document `` via PageRenderer. ### Method Not applicable (ViewHelper) ### Endpoint Not applicable (ViewHelper) ### Parameters #### Attributes - **path** (string) - Required - The URL or domain to prefetch. - **standalone** (boolean) - Optional - Whether to render as a standalone tag. - **rel** (string) - Optional - The relationship type, e.g., 'prefetch' or 'dns-prefetch'. Defaults to 'prefetch'. ### Request Example ```html ``` ### Response Not applicable (ViewHelper renders directly or registers asset) ``` -------------------------------- ### Get Current Date/Time Source: https://context7.com/fluidtypo3/vhs/llms.txt Retrieves the current date and time as a formatted string. Specify the desired `format` using PHP's date format characters. ```html {v:system.datetime(format: 'Y-m-d H:i:s')} ``` ```html Current year: {v:system.datetime(format: 'Y')} ``` -------------------------------- ### Try ViewHelper with 'then' and 'else' attributes for fallback Source: https://github.com/fluidtypo3/vhs/blob/development/Documentation/ViewHelpers/Try.rst This example shows a concise usage of the v:try ViewHelper using the 'then' and 'else' attributes. It attempts to encode an object to JSON; if this fails, it falls back to providing a predefined valid JSON string. This prevents breakage by JSON consumers. ```fluid {v:try(then: '{badObject -> v:format.json.encode()}', else: '{"validJson": "validValue"}')} ```