Push ViewHelper <f:push>
Add a value to a given array variable. If the variable is null or empty, it will be initialized as an empty array.
Examples ========
Add a value to the end of an array ----------------------------------
<f:variable name="tags"/> <f:for each="{newsItem.tags}" as="tag"> <f:push name="tags" value="{tag.title}" /> </f:for>Copied!Add a value with a key to an array ----------------------------------
If the key already exists, the value will be overridden.
<f:push name="tags" key="some-key" value="some-value" />Copied!
Go to the source code of this ViewHelper: PushViewHelper.php (GitHub).
Arguments
The following arguments are available for the push ViewHelper:
key
-
- Type
- string
Key that should be used in the array
name
-
- Type
- string
- Required
- 1
Name of variable to extend.
value
-
- Type
- mixed
Value to push to specified array variable. If not in arguments then taken from tag content.