[FLOW3-general] Making variables available for the Layout

Bastian Waidelich bastian at typo3.org
Fri Nov 2 13:08:12 CET 2012


François Suter wrote:

Hi François,

> [...] I would like to display the user's name inside the menu
> bar. Is there any way to assign a variable (the current account, in this
> case) early [...]

Of course you could create a ViewHelper for this, but assigning the 
variable is "cheaper" and more straightforward IMO.

Something that proved very useful for me was a common base controller. 
In that you can assign variables to the view very early in the 
initializeView() template method.
Additionally it might be useful to have the current account always 
accessible as protected member variable. This can be done in 
initializeAction(). See [1] for a working example.

HTH,
Bastian

[1] 
http://git.typo3.org/FLOW3/Packages/TYPO3.Conference.git?a=blob;f=Classes/Controller/AbstractBaseController.php;h=bcc8a3129e88429d3fec8db1ab52064f617fe567;hb=HEAD#l68


More information about the FLOW3-general mailing list