Documentation · ViewHelper reference

XSD schema file | vhs master

Variable / GetViewHelper

Variable: Get

ViewHelper used to read the value of a current template variable. Can be used with dynamic indices in arrays:

<v:variable.get name="array.{dynamicIndex}" />
<v:variable.get name="array.{v:variable.get(name: 'arrayOfSelectedKeys.{indexInArray}')}" />
<f:for each="{v:variable.get(name: 'object.arrayProperty.{dynamicIndex}')}" as="nestedObject">

Or to read names of variables which contain dynamic parts:

<!-- if {variableName} is "Name", outputs value of {dynamicName} -->
{v:variable.get(name: 'dynamic{variableName}')}

If your target object is an array with unsequential yet numeric indices (e.g. {123: 'value1', 513: 'value2'}, commonly seen in reindexed UID map arrays) use useRawKeys="TRUE" to indicate you do not want your array/QueryResult/Iterator to be accessed by locating the Nth element - which is the default behavior.

warning Do not try `useRawKeys="TRUE"` on QueryResult or ObjectStorage unless you are fully aware what you are doing. These particular types require an unpredictable index value - the SPL object hash value - when accessing members directly. This SPL indexing and the very common occurrences of QueryResult and ObjectStorage variables in templates is the very reason why `useRawKeys` by default is set to `FALSE`. /

  • Tag usage example

    <v:variable.get name="NULL" useRawKeys="1">
    	<!-- tag content - may be ignored! -->
  • Inline usage example

    {v:variable.get(name: 'NULL', useRawKeys: 1)}


Argument Description Type

Name of variable to retrieve


If TRUE, the path is directly passed to ObjectAccess. If FALSE, a custom and compatible VHS method is used

Required attribute

Revision history

commit da7677bc74f14e9a9300e4ba4487e52c3cb97642
Author: Claus Due <*****>
Date:   Sun Apr 20 01:13:33 2014 +0200

    [TASK] Switch to namespaces

commit f16494865266f00f4df185236b7856aa96841039
Author: Xaver Maierhofer <*****>
Date:   Sat Jun 7 22:58:04 2014 +0200

    [TASK] Replace old namespace and move v:if to v:condition and v:var to v:variable in documentaion and readme

commit 53b0c30204bc1f46f2b2c6cb13c33c49d6c39f3e
Author: Xaver Maierhofer <*****>
Date:   Sun Jun 8 14:42:09 2014 +0200

    [TASK] Update vhs 2.0 namespaces
    Variable in variable PHP

commit 12ff0ddfb8d36c51f2d3befde7ae812177c80d5d
Author: Xaver Maierhofer <*****>
Date:   Wed Jun 11 00:01:47 2014 +0200

    [TASK] CGL remove use leading backslash
    PHP Docs
    Note that for namespaced names (fully qualified namespace names containing namespace separator, such as Foo\Bar as opposed to global names that do not, such as FooBar),
    the leading backslash is unnecessary and not recommended, as import names must be fully qualified, and are not processed relative to the current namespace.

commit 716b251b6470782dbc09ca6e883b00cb75e5e440
Author: Claus Due <*****>
Date:   Thu Jan 15 04:52:28 2015 +0100

    [TASK] More test ports

commit 8bb2fc5ee124ba19b0a0ab8e061c9a153fc4651f
Author: Xaver Maierhofer <*****>
Date:   Sun Jan 18 17:56:13 2015 +0100

    [TASK] Reference Copyright to file