.. include:: ../Includes.txt
.. _viewhelpers:
.. image:: ../Images/logo_typotonic.jpg
:width: 250px
ViewHelpers
-----------
All ViewHelpers are available through the namespace ``t:``
|
The namespace is automatically active, when TypoTonic is installed.
You can surround your templates with the following code, to support autocompletion in your IDE.
.. code-block:: html
...Your Code here...
ViewHelpers\\Template\\RenderViewHelper
#######################################
This ViewHelper renders template files, either defined in the plugin TypoScript or a manual file path.
+---------------------+----------------+------------------------------------------------------------------------------+
| Argument | Type | Description |
+=====================+================+==============================================================================+
| template | string | Please enter a valid file or a template identifier, configured in TypoScript |
| | | ``plugin.tx_tonic.templates`` |
+---------------------+----------------+------------------------------------------------------------------------------+
| arguments | array | The arguments that will be included in the template |
+---------------------+----------------+------------------------------------------------------------------------------+
| variables | array | Ids of additional template variables to inject |
+---------------------+----------------+------------------------------------------------------------------------------+
| cache | boolean | Enable or disable caching of the output |
+---------------------+----------------+------------------------------------------------------------------------------+
| lifetime | int | Sets the cache lifetime for the cache in seconds |
+---------------------+----------------+------------------------------------------------------------------------------+
| cacheIdentifier | string | Custom cache identifier |
+---------------------+----------------+------------------------------------------------------------------------------+
Usage:
.. code-block:: html
{t:template.render(template:'movieMini',arguments:'{record:record}')}
ViewHelpers\\Datatype\\GetViewHelper
####################################
Fetch a datatype by uid
+---------------------+----------------+------------------------------------------------------------------------------+
| Argument | Type | Description |
+=====================+================+==============================================================================+
| uid | int | The Uid of the datatype |
+---------------------+----------------+------------------------------------------------------------------------------+
| onlyEnabled | boolean | Fetch only and enabled datatype |
+---------------------+----------------+------------------------------------------------------------------------------+
Returns: ``Aix\Tonic\Domain\Model\Datatype``
Usage:
.. code-block:: html
{t:datatype.get(id:'1',onlyEnabled:'0')}
ViewHelpers\\Record\\GetViewHelper
##################################
Fetch a record by uid
+---------------------+-----------------------------------+---------------------------------------------------------+
| Argument | Type | Description |
+=====================+===================================+=========================================================+
| uid | int | The Uid of the datatype |
+---------------------+-----------------------------------+---------------------------------------------------------+
| datatype | Aix\Tonic\Domain\Model\Datatype | Fetch only and enabled datatype |
+---------------------+-----------------------------------+---------------------------------------------------------+
| onlyEnabled | boolean | Fetch only and enabled datatype |
+---------------------+-----------------------------------+---------------------------------------------------------+
Returns: ``Aix\Tonic\Domain\Model\AbstractRecordModel``
Usage:
.. code-block:: html
{t:record.get(id:'1',datatype:datatype,onlyEnabled:'0')}
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 ``{detailPid}``.
For all additional link parameters, refer to `f:link.page
`_.
.. code-block:: html
Link
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 ``{detailPid}``.
For all additional link parameters, refer to `f:uri.page
`_.
.. code-block:: html
{t:uri.record(record:record,pageUid:detailPid)}
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
*********************
+---------------------+-----------------+----------------------------------------------------+
| Key | Value Type | Description / Values |
+=====================+=================+====================================================+
| condition | string | AND / OR |
+---------------------+-----------------+----------------------------------------------------+
| filters | array | Array with filters |
+---------------------+-----------------+----------------------------------------------------+
Filter
******
+------------------+----------------+----------------------------------------+
| Key | Value Type | Description / Values |
+==================+================+========================================+
| field | string | The field name to filter |
+------------------+----------------+----------------------------------------+
| operator | string | The filter operator |
| | | see the ``Operators`` table |
+------------------+----------------+----------------------------------------+
| value | mixed | The value to search for |
+------------------+----------------+----------------------------------------+
Operators
*********
+------------------------------------+---------------------------+
| Operator Value | Operator SQL |
+====================================+===========================+
| ``equal`` | ``=`` |
+------------------------------------+---------------------------+
| ``not_equal`` | ``!=`` |
+------------------------------------+---------------------------+
| ``in`` | ``IN`` |
+------------------------------------+---------------------------+
| ``not_in`` | ``NOT IN`` |
+------------------------------------+---------------------------+
| ``less`` | ``<`` |
+------------------------------------+---------------------------+
| ``less_or_equal`` | ``<=`` |
+------------------------------------+---------------------------+
| ``greater`` | ``>`` |
+------------------------------------+---------------------------+
| ``greater_or_equal`` | ``>=`` |
+------------------------------------+---------------------------+
| ``between`` | ``BETWEEN`` |
+------------------------------------+---------------------------+
| ``begins_with`` | ``LIKE 'xyz%'`` |
+------------------------------------+---------------------------+
| ``not_begins_with`` | ``NOT LIKE 'xyz%'`` |
+------------------------------------+---------------------------+
| ``contains`` | ``LIKE '%xyz%'`` |
+------------------------------------+---------------------------+
| ``not_contains`` | ``NOT LIKE '%xyz%'`` |
+------------------------------------+---------------------------+
| ``ends_with`` | ``LIKE '%xyz'`` |
+------------------------------------+---------------------------+
| ``not_ends_with`` | ``NOT LIKE '%xyz'`` |
+------------------------------------+---------------------------+
| ``is_empty`` | ``= ''`` |
+------------------------------------+---------------------------+
| ``is_not_empty`` | ``!= ''`` |
+------------------------------------+---------------------------+
| ``is_null`` | ``NULL`` |
+------------------------------------+---------------------------+
| ``is_not_null`` | ``NOT NULL`` |
+------------------------------------+---------------------------+
.. code-block:: html
{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.
.. code-block:: html
{t:group.recordsByProperty(records:records,property:'propertyName')}