Skip to content

ViewHelpers

Markus Hackel edited this page Oct 12, 2017 · 9 revisions

Focuspoint

BackgroundPositionViewHelper

This ViewHelper is for use with EXT:focuspoint. It returns CSS inline style for the background-position which is calculated by the focuspoint coordinates of the image (see Extension Documentation).

{namespace xmTools = Xima\XmTools\ViewHelpers}

<!-- Inline Notation (probably the standard use case): -->
{xmTools:focuspoint.backgroundPosition(focus_point_x: image.properties.focus_point_x, focus_point_y: image.properties.focus_point_y)}

Example

<figure class="skd-image-header-inner" {xmTools:focuspoint.backgroundPosition(focus_point_x: image.properties.focus_point_x, focus_point_y: image.properties.focus_point_y)}>
    <xmTools:responsiveImage image="{image}"
        title="{image.title}"
        alt="{image.alternative}"
        treatIdAsReference="1"
        sizes="{settings.xmTools.responsiveImage.sizes.museumheadimage}"
        additionalAttributes="{data-image-bg:data-image-bg}" />
</figure>

Media

EmbedUrlViewHelper

This ViewHelper returns the Embed-URL (and only the URL) of a Youtube or Vimeo video from an Object (Domain Model or FAL Resource) or from an Array.

{namespace xmTools = Xima\XmTools\ViewHelpers}

<xmTools:media.embedUrl file="{mediaObject}">
    <!-- tag content - may be ignored! -->
</xmTools:media.embedUrl>

<!-- Inline Notation (probably the standard use case): -->
{xmTools:media.embedUrl(file: mediaObject)}

Example

<div class="video-click" data-src="{xmTools:media.embedUrl(file: media)}" data-title="{media.title}">
    <f:image image="{media}" alt="{media.alt}" />
</div>

Object

ArrayElementViewHelper

This ViewHelper returns an array element by key.

{namespace xmTools = Xima\XmTools\ViewHelpers}
<xmTools:object.arrayElement array="{array}" key="{key}" variableName="myValue">
    {myValue}
</xmTools:object.arrayElement>

ArrayExplodeViewHelper

This ViewHelper explodes an array by given delimiter. It ist basically equal to PHP explode().

{namespace xmTools = Xima\XmTools\ViewHelpers}
<f:for each="{xmTools:object.ArrayExplode(delimiter:',',string:someString)}" as="item">
    {item}
</f:for>

ArrayImplodeViewHelper

This ViewHelpers implodes an array with given glue. It is basically equal to PHP implode(). If array items are array themselves a key ($functionOrKey) can be specified. If array items are objects a function to retrieve a certain value for the implode can be specified ($functionOrKey).

{namespace xmTools = Xima\XmTools\ViewHelpers}
<xmTools:object.ArrayImplode glue=", " array="{someArray}", functionOrKey="string|int">

Inline notation:

{xmTools:object.arrayImplode(glue: ', ' array: someArray, functionOrKey: 'string|int')}

GetCategoriesViewHelper

This ViewHelper returns the child categories of a given category including an options array for use within a select field.

Example

{namespace xmTools = Xima\XmTools\ViewHelpers}
<xmTools:getCategories parentCategory="{rootCategoryUid}" firstOptionLabel="--Please choose--" as="categories">
    <f:form.select name="category" options="{categories.options}"/>
</xmTools:getCategories>

<!-- Inline Usage -->
{xmTools:getCategories(parentCategory: rootCategoryUid, as: 'categories')}

Arguments

  • parentCategory: uid of the category in question, Type: integer
  • firstOptionLabel: Label of the first option in the options array which appears as first entry within the select field ('parent' (Default) for the Label of the parent category, 'none': no option with value = 0 will be rendered, '<your_own_string>' (any custom string)), Type: string
  • as: If specified, a template variable with this name containing the requested data will be inserted instead of returning it. Type: string

ResponsiveImageViewHelper

See detailed description