ViewHelpers
ViewHelpers
All ViewHelpers are available through the namespace <span class="pre">t:</span>| The namespace is automatically active, when TypoTonic is installed.
You can surround your templates with the following code, to support autocompletion in your IDE.
<span></span><span class="p"><</span><span class="nt">html</span>
<span class="na">lang</span><span class="o">=</span><span class="s">"en"</span>
<span class="na">data-namespace-typo3-fluid</span><span class="o">=</span><span class="s">"true"</span>
<span class="na">xmlns:f</span><span class="o">=</span><span class="s">"http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"</span>
<span class="na">xmlns:t</span><span class="o">=</span><span class="s">"http://typo3.org/ns/Aix/Tonic/ViewHelpers"</span><span class="p">></span>
...Your Code here...
<span class="p"></</span><span class="nt">html</span><span class="p">></span>
ViewHelpers\Template\RenderViewHelper
This ViewHelper renders template files, either defined in the plugin TypoScript or a manual file path.
ArgumentTypeDescriptiontemplatestringPlease enter a valid file or a template identifier, configured in TypoScript <span class="pre">plugin.tx_tonic.templates</span>argumentsarrayThe arguments that will be included in the templatevariablesarrayIds of additional template variables to injectcachebooleanEnable or disable caching of the outputlifetimeintSets the cache lifetime for the cache in secondscacheIdentifierstringCustom cache identifierUsage:
<span></span><span class="c"><!-- Inline Notation @see https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/8-Fluid/1a-inline-syntax.html --></span>
{t:template.render(template:'movieMini',arguments:'{record:record}')}
<span class="c"><!-- Basic Notation --></span>
<span class="p"><</span><span class="nt">t:template.render</span> <span class="na">template</span><span class="o">=</span><span class="s">"movieMini"</span> <span class="na">arguments</span><span class="o">=</span><span class="s">"{record:record}"</span> <span class="na">variables</span><span class="o">=</span><span class="s">"{0:12,1:35}"</span> <span class="p">/></span>
<span class="p"><</span><span class="nt">t:template.render</span> <span class="na">template</span><span class="o">=</span><span class="s">"fileadmin/templates/tonic/movies/mini.html"</span> <span class="na">arguments</span><span class="o">=</span><span class="s">"{record:record}"</span> <span class="p">/></span>
ViewHelpers\Datatype\GetViewHelper
Fetch a datatype by uid
ArgumentTypeDescriptionuidintThe Uid of the datatypeonlyEnabledbooleanFetch only and enabled datatypeReturns: <span class="pre">Aix\Tonic\Domain\Model\Datatype</span>
Usage:
<span></span><span class="c"><!-- Inline Notation --></span>
{t:datatype.get(id:'1',onlyEnabled:'0')}
<span class="c"><!-- Basic Notation --></span>
<span class="p"><</span><span class="nt">t:datatype.get</span> <span class="na">uid</span><span class="o">=</span><span class="s">"1"</span> <span class="na">onlyEnabled</span><span class="o">=</span><span class="s">"0"</span> <span class="p">/></span>
ViewHelpers\Record\GetViewHelper
Fetch a record by uid
ArgumentTypeDescriptionuidintThe Uid of the datatypedatatypeAixTonicDomainModelDatatypeFetch only and enabled datatypeonlyEnabledbooleanFetch only and enabled datatypeReturns: <span class="pre">Aix\Tonic\Domain\Model\AbstractRecordModel</span>
Usage:
<span></span><span class="c"><!-- Inline Notation --></span>
{t:record.get(id:'1',datatype:datatype,onlyEnabled:'0')}
<span class="c"><!-- Basic Notation --></span>
<span class="p"><</span><span class="nt">t:record.get</span> <span class="na">uid</span><span class="o">=</span><span class="s">"1"</span> <span class="na">datatype</span><span class="o">=</span><span class="s">"{datatype}"</span> <span class="na">onlyEnabled</span><span class="o">=</span><span class="s">"0"</span> <span class="p">/></span>
ViewHelpers\Link\RecordViewHelper
This ViewHelper can create a html link tag with a record parameter and a detail page id. The Detail Page Id is normally configured in the Plugin itself and is delivered through <span class="pre">{detailPid}</span>.
For all additional link parameters, refer to f:link.page.
<span></span><span class="p"><</span><span class="nt">t:link.record</span> <span class="na">record</span><span class="o">=</span><span class="s">"{record}"</span> <span class="na">pageUid</span><span class="o">=</span><span class="s">"{detailPid}"</span><span class="p">></span>Link<span class="p"></</span><span class="nt">t:link.record</span><span class="p">></span>
ViewHelpers\Uri\RecordViewHelper
This ViewHelper creates a url-link to a record. The Detail Page Id is normally configured in the Plugin itself and is delivered through <span class="pre">{detailPid}</span>.
For all additional link parameters, refer to f:uri.page.
<span></span><span class="c"><!-- Inline Notation --></span>
{t:uri.record(record:record,pageUid:detailPid)}
<span class="c"><!-- Basic Notation --></span>
<span class="p"><</span><span class="nt">t:uri.record</span> <span class="na">record</span><span class="o">=</span><span class="s">"{record}"</span> <span class="na">pageUid</span><span class="o">=</span><span class="s">"{detailPid}"</span> <span class="p">/></span>
ViewHelpers\Filter\RecordsViewHelper
The filter records ViewHelper can add subqueries to the records query-result, that is injected to your templates. You can manually add additional filters to created dynamic results within fluid templates.
A filter contains multiple information like the following table shows
Basic filtering setup
KeyValue TypeDescription / ValuesconditionstringAND / ORfiltersarrayArray with filters
Filter
KeyValue TypeDescription / ValuesfieldstringThe field name to filteroperatorstringThe filter operator see the <span class="pre">Operators</span> tablevaluemixedThe value to search for
Operators
Operator ValueOperator SQL`equal<span class="pre">=</span>not_equal<span class="pre">!=</span>in<span class="pre">IN</span>not_in<span class="pre">NOT</span> <span class="pre">IN</span>less<span class="pre"><</span>less_or_equal<span class="pre"><=</span>greater<span class="pre">></span>greater_or_equal<span class="pre">>=</span>between<span class="pre">BETWEEN</span>begins_with<span class="pre">LIKE</span> <span class="pre">'xyz%'</span>not_begins_with<span class="pre">NOT</span> <span class="pre">LIKE</span> <span class="pre">'xyz%'</span>contains<span class="pre">LIKE</span> <span class="pre">'%xyz%'</span>not_contains<span class="pre">NOT</span> <span class="pre">LIKE</span> <span class="pre">'%xyz%'</span>ends_with<span class="pre">LIKE</span> <span class="pre">'%xyz'</span>not_ends_with<span class="pre">NOT</span> <span class="pre">LIKE</span> <span class="pre">'%xyz'</span>is_empty<span class="pre">=</span> <span class="pre">''</span>is_not_empty<span class="pre">!=</span> <span class="pre">''</span>is_null<span class="pre">NULL</span>is_not_null``NOT NULL````
{t:filter.records(records:records,filters:{condition:'AND',rules:{0:{field:'title',operator:'contains',value:'sales'}}})}
<t:filter.records records="{records}" filters="{condition:'AND',rules:{0:{field:'title',operator:'contains',value:'sales'}}}" />
### ViewHelpers\\Group\\RecordsByPropertyViewHelper
This ViewHelper re-groups given records by a custom property value. It creates an multidimensional array as return value, grouped by the property value of which the property name was given.
{t:group.recordsByProperty(records:records,property:'propertyName')}
<t:group.records records="{records}" property="propertyName" />
