Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Latest commit

 

History

History
1973 lines (1283 loc) · 47.3 KB

File metadata and controls

1973 lines (1283 loc) · 47.3 KB

Fluid

notice - Draft

Change the {{draft}} marker to {{review}} when you need a reviewer for text and TypoScript. info [deprecated wiki link]

notice - This information is outdated

This page is related to the outdated TYPO3 version 6.2 and is no longer being updated. For information about Fluid for newer versions, see https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Fluid/Index.html

Also see FluidSyntax.

Fluid / Extbase | Extbase is a backport of some

features of Flow (the PHP framework on which TYPO3 Neos will be built) to TYPO3 CMS.
With Fluid, the new templating system, all the code for the view logic moves to the template.
 
current version:  
TYPO3 6.2 [not available anymore] Extbase/Fluid 6.2
earlier releases:  
TYPO3 6.1 [not available anymore] Extbase/Fluid 6.1
TYPO3 6.0 [not available anymore] Extbase/Fluid 6.0
TYPO3 4.7 [not available anymore] Extbase/Fluid 4.7
TYPO3 4.6 [not available anymore] Extbase/Fluid 1.4
TYPO3 4.5 [not available anymore] Extbase/Fluid 1.3
TYPO3 4.4 [not available anymore] Extbase/Fluid 1.2
TYPO3 4.3 [not available anymore] Extbase/Fluid 1.0

Ressources:

  • `Fluid Guide

<https://docs.typo3.org/typo3cms/ ExtbaseGuide/Fluid/Index.html>`__ - `Extbase Documentation on

Typo3 Forge <h

ttps://forge.typo3.org/projects/t ypo3v4-mvc/wiki/Documentation>`__

[not available anymore]
flow.typo3.org/documentation/>`__
[not available anymore]

tation <fluid-inline-notation>`__ - `T3Doc/Fluidtemplate by

exam

ple <fluidtemplate-by-example>`__

 

Collection of fluid [deprecated wiki link] / extbase [deprecated wiki link] hints

Accessing a view helper

Acessing a viewHelper from another viewHelper for instance:

PHP Script [deprecated wiki link]
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$viewHelper = $objectManager->get($viewHelperName);
$result = $viewHelper->render($param1, $param2);

Including a Fluid plugin through ext_tables.php

PHP Script [deprecated wiki link]
/**
 * Register an Extbase PlugIn into backend's list of plugins
 */
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
   'Addresses',                    // The name of the extension in UpperCamelCase
   'Pi1',                      // A unique name of the plugin in UpperCamelCase
   'Address Management'              // A title shown in the backend dropdown field
);

Configure a Fluid plugin through ext_localconf.php

PHP Script [deprecated wiki link]
/**
 * Configure the Extbase Dispatcher
 */
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
   'Vendor.' . $_EXTKEY,                   // The name of the extension in UpperCamelCase
   'Pi1',                      // A unique name of the plugin in UpperCamelCase
   array(
       'Address' => 'index,show',       // The first controller and its first action will be the default
   ),
   array(
       'Address' => 'index,show',       // An array of non-cachable controller-action-combinations (they must already be enabled)
   )
);

Accessing TS configuration in the controller

The TS configuration can be accessed through

PHP Script [deprecated wiki link]
$this->settings

Adding AdditionalHeaderdata (for example Stylesheets)

Use

PHP Script [deprecated wiki link]
$this->response->addAdditionalHeaderData()

Better is the method (not for uncached actions) to include js or css.

PHP Script [deprecated wiki link]
$GLOBALS['TSFE']->getPageRenderer()->

Example:

PHP Script [deprecated wiki link]
$this->response->addAdditionalHeaderData('<link rel="stylesheet" href="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('extkey') . 'Resources/Public/Stylesheets/index.css" />');

Accessing the current request (f.e. for retrieving $_GET vars)

You can access the current request with

PHP Script [deprecated wiki link]
$currentRequest = $this->variableContainer->get('view')->getRequest();

If you want to access f.e. a $_GET param use

PHP Script [deprecated wiki link]
$this->variableContainer->get('view')->getRequest()->getArgument('name of the GET var');

or to access all arguments:

PHP Script [deprecated wiki link]
$this->variableContainer->get('view')->getRequest()->getArguments();

You can also check if an argument exists with

PHP Script [deprecated wiki link]
$this->variableContainer->get('view')->getRequest()->hasArgument('name of the GET var');

Standard View Helpers

f:alias

Used to declare one or more variables that will only be valid within the f:alias tag.

Example:

XML / HTML [deprecated wiki link]
<f:alias map="{x: foo.bar.baz, y: foo.bar.baz.name}">
   {x.name} or {y}
</f:alias>

f:base

Outputs the base-tag in HTML

Example:

XML / HTML [deprecated wiki link]
<f:base />

Output:

XML / HTML [deprecated wiki link]
<base href="http://example.com/"></base>

f:cObject

you can get output from typoscript based on current data

Example:

XML / HTML [deprecated wiki link]
<f:cObject typoscriptObjectPath="lib.calc" data="45 + 34 * 2" />

in conjunction with:

lib.calc = TEXT
lib.calc {
  current = 1
  prioriCalc = 1
}

Output:

158

(as TYPO3 prioriCalc ignores precedence of * and calculates (45 + 34) * 2 )

Example2:

XML / HTML [deprecated wiki link]
<f:cObject typoscriptObjectPath="lib.replace_umlauts">Übergröße</f:cObject>

in conjunction with:

lib.replace_umlauts = TEXT
lib.replace_umlauts {
  current = 1
  stdWrap.replacement {
    1 {
      search = ä
      replace = ae
    }
    2 {
      search = ö
      replace = oe
    }
    3 {
      search = ü
      replace = ue
    }
    4 {
      search = ß
      replace = ss
    }
    5 {
      search = Ä
      replace = Ae
    }
    6 {
      search = ö
      replace = Oe
    }
    7 {
      search = ü
      replace = ue
    }
  }
}

Output:

Uebergroesse

http://www.t3node.com/blog/combining-fluid-viewhelpers-and-typoscript-in-typo3-5-basic-examples/ [not available anymore]

f:comment

Write a comment that does not get outputted in the final HTML.

Example:

XML / HTML [deprecated wiki link]
<f:comment>
This partial expects the following parameters:
- "datum": Single data object with a "value" property
- "key": Name of datum
</f:comment>

f:count

Counts the number of elements in an array

Example:

XML / HTML [deprecated wiki link]
<f:count subject="{myarray}" />

Output: 5

Example for usage in condtions:

XML / HTML [deprecated wiki link]
<f:if condition="{myarray -> f:count()} > 3">

// do something

</f:if>

f:cycle

If used inside a for-loop will rotate the values given.

Example:

XML / HTML [deprecated wiki link]
<f:for each="{0:1, 1:2, 2:3, 3:4}" as="foo">
  <f:cycle values="{0: '..', 1: '--', 2: 'xx'}" as="cycle">
    {cycle}
  </f:cycle>
</f:for>

Output: ..--xx..

Usage: Use to create Zebra-Styles, Rotating Templates, ...

f:debug

Debugs the content inside the tag, Outputs the title in front

Example:

XML / HTML [deprecated wiki link]
<f:debug title="Debug of MyArray">{myarray}</f:debug>
<f:debug title="All available variables">{_all}</f:debug>

To modify the depth of an object's properties, use the maxDepth attribute. It defaults to 8:

XML / HTML [deprecated wiki link]
<f:debug maxDepth="3">{data}</f:debug>

By default, the dump is positioned above all elements on the page, and on the top left. To show it at the place f:debug is called at, activate "inline":

XML / HTML [deprecated wiki link]
<f:debug inline="true">{data}</f:debug>

warning - Message

<f:debug> does not output properties of plain stdClass objects in TYPO3 < 6.2.5

f:for

Traverses an Array wholy

Example:

XML / HTML [deprecated wiki link]
<ul>
   <f:for each="{shoppinglist}" as="food" key="number" iteration="itemIteration">
     <li class="item{f:if(condition: itemIteration.isFirst, then: 'first-child')}">{number}: {food}</li>
   </f:for>
</ul>

Output:

XML / HTML [deprecated wiki link]
</ul>
  <li class="item first-child">4: apples</li>
  <li class="item">3: choclate</li>
  <li class="item">25: beer</li>
  <li class="item">10: frozen pizza</li>
</ul>

Available iterator values:
itemIteration.index (0 based index of the iteration)
itemIteration.cycle (the same as index, but starting from 1)
itemIteration.total (total number of items)
itemIteration.isFirst (TRUE for the first item in the iteration)
itemIteration.isLast (TRUE for the last item in the iteration)
itemIteration.isOdd (TRUE for odd cycles 1,3,5,...)
itemIteration.isEven (TRUE for even cycles 2,4,6,...)

f:form

Outputs a HTML form. The data is submitted via POST request (you can change that by setting method="get").

Inside the form you can use form fields [deprecated wiki link] (see below).

XML / HTML [deprecated wiki link]
<f:form action="...">...</f:form>
<f:form action="..." controller="..." package="..." enctype="multipart/form-data"> ... </f:form>

A form to change the properties of a domain object. This binds the values to the form fields.

XML / HTML [deprecated wiki link]
<f:form action="..." name="customer" object="{customer}">
  <f:form.hidden property="id" />
  <f:form.textfield property="name" />
</f:form>

form fields

f:form.checkbox

XML / HTML [deprecated wiki link]
<f:form.checkbox name="myCheckBox" value="someValue" />
Output: <input type="checkbox" name="myCheckBox" value="someValue" />

You can also perfom simple boolean operations.

XML / HTML [deprecated wiki link]
<f:form.checkbox name="myCheckBox" value="someValue" checked="{object.value} == 5" />
Output: <input type="checkbox" name="myCheckBox" value="someValue" checked="checked" /> (depending on {object})

Bind to an object property

XML / HTML [deprecated wiki link]
<f:form.checkbox property="interests" value="TYPO3" />
Output: <input type="checkbox" name="user[interests][]" value="TYPO3" checked="checked" /> (depending on property "interests")

f:form.errors

Iterates through errors of the request

DEPRECATED: This ViewHelper is not available anymore in TYPO3 6.2.

XML / HTML [deprecated wiki link]
<ul class="errors">
  <f:form.errors>
    <li>{error.code}: {error.message}</li>
  </f:form.errors>
</ul>

Output:
<ul>
  <li>1234567890: Validation errors for argument "newBlog"</li>
</ul>

f:form.hidden

Renders an <input type="hidden" ...> tag.

XML / HTML [deprecated wiki link]
<f:form.hidden name="myHiddenValue" value="42" />

Output:
<input type="hidden" name="myHiddenValue" value="42" />

f:form.password

Creates a textbox for password input.

XML / HTML [deprecated wiki link]
<f:form.password name="myPassword" />

Output:
<input type="password" name="myPassword" value="default value" />

f:form.radio

Creates a radio button

XML / HTML [deprecated wiki link]
<f:form.radio name="myRadioButton" value="someValue" />

Output: <input type="radio" name="myRadioButton" value="someValue" />
XML / HTML [deprecated wiki link]
<f:form.radio name="myRadioButton" value="someValue" checked="{object.value} == 5" />

Output: <input type="radio" name="myRadioButton" value="someValue" checked="checked" /> (depending on {object})
XML / HTML [deprecated wiki link]
<f:form.radio property="newsletter" value="1" /> yes
<f:form.radio property="newsletter" value="0" /> no

Output:
<input type="radio" name="user[newsletter]" value="1" checked="checked" /> yes
<input type="radio" name="user[newsletter]" value="0" /> no
(depending on property "newsletter")

f:form.select

Renders a <select> dropdown list. The simplest way is to supply an associative array, where the key is used as option key and the value as human-readable name.

XML / HTML [deprecated wiki link]
<f:form.select name="paymentOptions" options="{payPal: 'PayPal', visa: 'Visa Card'}" />

To preselect a value simply specify the attribute value="...". In this example: value="visa". If it is a multi-select box (multiple="true"), then value can be an array, too.

Binding to domain objects

XML / HTML [deprecated wiki link]
<f:form.select name="users" options="{userArray}" optionValueField="id" optionLabelField="firstName" />

In this example userArray is an array of "User" domain objects with no array key. $user->getId() and $user->getFirstName() is used to retrieve the key and the display name. The value attribute in this case would expect a "User" domain object.

f:form.submit

XML / HTML [deprecated wiki link]
<f:form.submit name="mySubmit" value="Send Mail" />

Output: <input type="submit" name="mySubmit" value="Send Mail" />

f:form.textarea

XML / HTML [deprecated wiki link]
<f:form.textarea cols="20" rows="5" name="myTextArea" value="This is shown inside the textarea" />

Output: <textarea cols="20" rows="5" name="myTextArea">This is shown inside the textarea</textarea>

f:form.textbox

DEPRECATED: use f:form.textfield [deprecated wiki link] instead!

f:form.textfield

XML / HTML [deprecated wiki link]
<f:form.textfield name="myTextBox" value="some value" />

Output: <input type="text" name="myTextBox" value="some value" />

f:form.upload

Generates an <input type="file"> element. Make sure to set enctype="multipart/form-data" on the form!

XML / HTML [deprecated wiki link]
<f:form.upload name="file" />

Output: <input type="file" name="file" />

format

f:format.crop

Example:

XML / HTML [deprecated wiki link]
<f:format.crop maxCharacters="17" append="&nbsp;[...]">This is some very long text</f:format.crop>

f:format.currency

Formats a number to resemble a currency.

XML / HTML [deprecated wiki link]
<f:format.currency currencySign="€" decimalSeparator="," thousandsSeparator=".">1234.56</f:format.currency>

Output: 1.234,56 €

f:format.date

XML / HTML [deprecated wiki link]
<f:format.date format="d.m.Y - H:i:s">+1 week 2 days 4 hours 2 seconds</f:format.date>

Usage with unix timestamps:

XML / HTML [deprecated wiki link]
<f:format.date format="d.m.Y - H:i:s">@{your_timestamp}</f:format.date>

See also: PHP Manual date

Be aware: as the php function date() is not capable of localisation you have no chance to get local named times (weekday, month)

Since Feb 2013 the functionality of this viewhelper is extended: you can use strftime-format-strings (recognized by the usage of '%' in the format-string) and use localisation for weekdays and month.

See also: PHP Manual strftime

f:format.html

Renders Code through lib.parseFunc_RTE or a custom parsing function. To be used with RTE input.

f:format.htmlentitiesDecode

Decode special HTML characters that Fluid encodes by default (&, <, >, ")

XML / HTML [deprecated wiki link]
<script type="text/javascript">
    var json = <f:format.htmlentitiesDecode>{jsonVarFromControllerAction}</f:format.htmlentitiesDecode>;
</script>

f:format.raw

Outputs an argument/value without any escaping.

XML / HTML [deprecated wiki link]
<f:format.raw>{string}</f:format.raw>

Outputs: Content of {string} without any escaping.

XML / HTML [deprecated wiki link]
<f:format.raw value="{string}" />
Inline
XML / HTML [deprecated wiki link]
{string -> f:format.raw()}

f:format.nl2br

Makes <br /> tags out of new lines.

XML / HTML [deprecated wiki link]
<f:format.nl2br>Some text with
newlines in it.</f:format.nl2br>

Output:

Some text with
newlines in it.

f:format.number

Formats numbers country-specific

XML / HTML [deprecated wiki link]
<f:format.number decimals="1" decimalSeparator="," thousandsSeparator=".">2345.678</f:format.number>

Output: 2.345,6

f.format.padding

Adds whitespace or a user-defined string to a string (using the PHP str_pad function).

XML / HTML [deprecated wiki link]
<f:format.padding padLength="10" padString="_">text</f:format.padding>

Output: text______

See also: PHP Manual str_pad

f.format.printf

Formats a string with the PHP printf function.

XML / HTML [deprecated wiki link]
<f:format.printf arguments="{0: 34567890, 1: 'some text'}">We can display %2$s and format numbers like this: %1$.3e</f:format.printf>
<f:format.printf arguments="{number: 12345}">%d</f:format.printf>

Output:

We can display some text and format numbers like this: 3.456e+7

12345

See also: PHP Manual printf

f:groupedFor

Sorts a multidimensional array in another dimension.

XML / HTML [deprecated wiki link]
<ul>
   <f:groupedFor each="{0: {name: 'apple', color: 'green'}, 1: {name: 'cherry', color: 'red'}, 2: {name: 'banana', color: 'yellow'}, 3: {name: 'strawberry', color: 'red'}}" as="fruitsOfThisColor" groupBy="color" groupKey="color">
     <li>
       {color} fruits:
       <ul>
         <f:for each="{fruitsOfThisColor}" as="fruit" key="label">
           <li>{label}: {fruit.name}</li>
         </f:for>
       </ul>
     </li>
   </f:groupedFor>
 </ul>

f:if, f:then, f:else

Conditional Output

See https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/If.html for more examples. BooleanParserTest.php lists allowed constructs.

Examples:

XML / HTML [deprecated wiki link]
<f:if condition="{myvar}">
  Displayed if myvar is neither an empty string nor "0".
</f:if>

<f:if condition="{myvar}">
  <f:then>
    Displayed if myvar is neither an empty string nor "0".
  </f:then>
  <f:else>
    Displayed if myvar IS an empty string or "0".
  </f:else>
</f:if>

Inline:

XML / HTML [deprecated wiki link]
<section class="{f:if(condition: record.show, then: 'visible-record', else: 'hide')}">

Strings

Since TYPO3 6.1 a string comparison can easily be done:

XML / HTML [deprecated wiki link]
<f:if condition="{myvar} == 'foobar'">
  Displayed if myvar is equal to the string value "foobar"
</f:if>

Inline notation:

XML / HTML [deprecated wiki link]
{f:if(condition:'{variable}==\'foo\'', then:'Hello')}
{f:if(condition:'{variable}=="foo"', then:'Hello')}

Integers

It is possible, to do some comparance of integer values.

XML / HTML [deprecated wiki link]
<f:if condition="{rank} > 100">
  Will be shown if rank is > 100
</f:if>
<f:if condition="{rank} % 2">
  Will be shown if rank % 2 != 0.
</f:if>
<f:if condition="{rank} == {k:bar()}">
  Checks if rank is equal to the result of the ViewHelper "k:bar"
</f:if>

Inline notation:

XML / HTML [deprecated wiki link]
{f:if(condition:'{number}==1', then:'Hello')}

Booleans

Simply use integer comparison:

XML / HTML [deprecated wiki link]
<f:if condition="{enable} == 1">
  Feature enabled!
</f:if>
<f:if condition="{enable} == 0">
  Feature disabled!
</f:if>

Inline:

XML / HTML [deprecated wiki link]
{f:if(condition: enable, then: 'Feature enabled!')}
{f:if(condition: '{enable}==0', then: 'Feature disabled!')}

Comparing view helper output

It is possible to use the result of another viewhelper as condition for the if-statement. The double quotes of the inner view helper have to be changed to single quotes then.

XML / HTML [deprecated wiki link]
<f:if condition="<f:count subject='{post.comments}' /> > 0">
  <f:then>
    [...] Display comments here[...]
  </f:then>
  <f:else>
    No Comments found.
  </f:else>
</f:if>

Logical operators

Concatenating multiple comparisons with AND, OR or NOT is not possible in f:if. You can use v:if [not available anymore] from VHS for that - see the examples.

If you only need AND, you can stack all values into an object that will be compared:

XML / HTML [deprecated wiki link]
<f:if condition="{0:myvar, 1:secondvar} == {0:'test', 1:'bar'}">
  Displayed if myvar is "test" AND secondvar is "bar".
</f:if>

f:image

Renders the Image specified by the src-attribute. The image can be resized by adding width and/or height attributes (resizing happens on the fly using an instance of tslib_cObj internally). You can also specify 'c' or 'm' to the width and height attributes.

XML / HTML [deprecated wiki link]
<f:image src="uploads/pics/myImage.png" width="200" height="150" alt="My Image" />
XML / HTML [deprecated wiki link]
<f:image src="{f:uri.resource(path:'Images/myImage.png')}" width="200" height="150" alt="My Image" />

See also TYPO3 TypoScript Reference: Functions

f:layout

Selects a layout

Example:

XML / HTML [deprecated wiki link]
<f:layout name="Main" />

Links

f:link.action

Creates a link to an extbase action.

Example:

XML / HTML [deprecated wiki link]
<f:link.action action="myAction"> Do It! </f:link.action>

Example with arguments:

XML / HTML [deprecated wiki link]
<f:link.action action="myAction" controller="MyController" arguments="{argument: argument}">Do It!</f:link.action>

f:link.email

Email link with spamProtectEmailAddresses-settings.

Example:

XML / HTML [deprecated wiki link]
<f:link.email email="[email protected]" />

f:link.external

Creates an external link.

Example:

XML / HTML [deprecated wiki link]
<f:link.external uri="http://www.typo3.org" target="_blank">external link</f:link.external>

f:link.page

Creates a Typolink.

Example:

XML / HTML [deprecated wiki link]
<f:link.page>Current Page</f:link.page>

<f:link.page pageUid="23">Contact</f:link.page>

<f:link.page pageUid="13" additionalParams="{tt_news|news: 13}">Read whole news</f:link.page> (does not work with Fluid 1.3)
<f:link.page pageUid="13" additionalParams="{tt_news: '{news: 13}'}">Read whole news</f:link.page> (works with Fluid 1.3)

<f:link.page addQueryString="1" section="top">To Top</f:link.page>

<f:link.page pageUid="23" pageType="123">Generate PDF</f:link.page>

(only from TYPO3/Fluid 7.0) Creates a Typolink. Useful with link wizard values: 19 _blank - "testtitle with whitespace" &X=y

Example:

XML / HTML [deprecated wiki link]
<f:link.typolink parameter="{link}">Linktext</f:link.typolink>

<f:link.typolink parameter="{link}" target="_blank" class="ico-class" title="some title" additionalParams="&u=b" additionalAttributes="{type:'button'}">
    Linktext
</f:link.typolink>

f:uri.*

If you need just the link itself from a link ViewHelper and not the full link tag, the ViewHelpers <f:uri.action>, <f:uri.email>, <f:uri.external>, <f:uri.image>, <f:uri.page> should be used. The arguments are the same as for the ones of <f:link.

Examples:

XML / HTML [deprecated wiki link]
<f:uri.action action="myAction" controller="MyController" arguments="{argument: argument}" />
<f:uri.email email="[email protected]" />
<f:uri.page pageUid="23" />

Rendering links from the link wizard

If you are using the link wizard as described here you have to use your own View Helper. Example see here.

f:renderFlashMessages

Renders Flash-Messages. Deprecated. Use <f:flashMessages> instead!

Example:

XML / HTML [deprecated wiki link]
<f:renderFlashMessages />

f:flashMessages

Renders Flash-Messages. Optional Parameter is "renderMode"

Example:

XML / HTML [deprecated wiki link]
<f:flashMessages renderMode="div" />

f:render

Renders the content of a section or a partial.

XML / HTML [deprecated wiki link]
<f:render partial="itemForm" arguments="{item: item}" />

<f:render section="sectionname" />

See also: f:section [deprecated wiki link]

Parameters

By default, variables in current scope are not passed to the template that shall be rendered.

You can provide a list of variables to pass on:

XML / HTML [deprecated wiki link]
<f:render partial="itemForm" arguments="{item: item, count: itemCount}" />

or simply pass all parameters to the template:

XML / HTML [deprecated wiki link]
<f:render partial="itemForm" arguments="{_all}" />

f:section

With a section you can define a section within a template.

Example:

XML / HTML [deprecated wiki link]
<f:layout name="layoutname" />
<f:section name="content">
  //Define Section here
</f:section>

This section will be called from a layout with

XML / HTML [deprecated wiki link]
<f:render section="sectionname" />

f:switch

Simple view helper that allows you to render content depending on a given value or expression. It bahaves similar to a basic switch statement in PHP.

Example:

XML / HTML [deprecated wiki link]
<f:switch expression="{person.gender}">
  <f:case value="male">Mr.</f:case>
  <f:case value="female">Mrs.</f:case>
  <f:case default="1">unknown gender</f:case>
</f:switch>

Output: Mr. / Mrs. (depending on the value of {person.gender})

warning - Message

Up to TYPO3 7.0, f:switch prevents the template/partial from being cached and degrades performance - see bug #64449.

f:translate

Translate a given key or use the tag body as default.

Example:

XML / HTML [deprecated wiki link]
<f:translate key="label_recent_posts">Below are the most recent posts:</f:translate>

The viewhelper supports additional arguments via the "arguments"-attribute. These arguments are inserted into the translated text with sprintf.

Example:

XML / HTML [deprecated wiki link]
<f:translate key="author" arguments="{0: authorName}">Written by %s.</f:translate>

If the authorName is "Heinz", this becomes (in default translation): "Written by Heinz".


The translate viewhelper has an optional attribute "extensionName" which tells the viewhelper from which extension the language files will be used, normally from EXT:extension_name/Resources/Private/Language/locallang.xlf. This can be useful when using language files from another extension, or when using the fluid standalone view.

Example:

XML / HTML [deprecated wiki link]
<f:translate key="label_recent_posts" extensionName="blog_example">Below are the most recent posts:</f:translate>

additionalAttributes

Sometimes, you need some HTML attributes which are not part of the standard. As an example: If you use the Dojo JavaScript framework, using these non-standard attributes makes life a lot easier.

We think that the templating framework should not constrain the user in his possibilities -- thus, it should be possible to add custom HTML attributes as well, if they are needed. Our solution looks as follows:

Every view helper which inherits from AbstractTagBasedViewHelper has a special argument called additionalAttributes which allows you to add arbitrary HTML attributes to the tag.

If the link tag from above needed a new attribute called fadeDuration, which is not part of HTML, you could do that as follows:

<f:link.action ... additionalAttributes="{fadeDuration : 800}">
Link with fadeDuration set
</f:link.action>

This attribute is available in all tags that inherit from TYPO3FluidCoreViewHelperAbstractTagBasedViewHelper.

Things that do not work

Mathematical expessions

Fluid does not have a native way to e.g. make sums or products of numbers and variables. You have to use external view helpers [not available anymore] like <vhs:math.sum>.

Other resources