Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to assign variable in fluid?

I want viewhelper that can be helpful to assign variable in fluid, I dont want variable to be passed from controller.

like image 350
Vishal Tanna Avatar asked Jun 12 '15 13:06

Vishal Tanna


1 Answers

Install extension called vhs from TYPO3 repository

Define namespace like following at the top of your fluid template

{namespace v=FluidTYPO3\Vhs\ViewHelpers}

Then use set viewhelper

<v:variable.set name="test" value="12345" />
Value of test : {test}

{test} will return value 12345

For registering global variable

<v:variable.register.set name="test" value="12345"/>]

Get value of global variable

Value of global variable : <v:variable.register.get name="test">

Since TYPO3 8.7, fluid introduces viewhelper for the variable (No need of VHS)

<f:variable name="myvariable">My variable's content</f:variable>
<f:variable name="myvariable" value="My variable's content"/>

With inline style usage

{f:variable(name: 'myvariable', value: 'My variable\'s content')}
{myoriginalvariable -> f:variable.set(name: 'mynewvariable')}
like image 107
Mihir Bhatt Avatar answered Oct 05 '22 20:10

Mihir Bhatt