[FLOW3-general] Making variables available for the Layout

Pankaj Lele pankaj at lelesys.com
Wed Oct 31 18:33:04 CET 2012


Hi François,

 > In my Flow application (actually a FLOW3 1.1 app), I have a general
 > layout with some menu bar at the top. This menu bar is templated in the
 > Layout file. Now 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 on so that it is available for every controller/action
 > combination rather than having to load in every controller's every 
action?

By default only Settings of the package are available in the Fluid 
template as variable automatically.

The easiest way can be to define a AbstractController and have all your 
controllers extend this. In this AbstractController define method 
initializeAction() and in this method assign the account as variable. 
initializeAction() is called before any action.

Another complex approach can be by using AOP class and crosscutting all 
controller->actions. Then you will get the controller object and you 
need to use the ObjectAccess to use the protected $view property of it 
as there is no public $controller->getView() function available I think.

-Pankaj

-- 
Pankaj Lele
CTO - Lelesys, India
http://www.lelesys.com
Twitter: @pankajlele


More information about the FLOW3-general mailing list