How to set different template layouts for different modules in Symfony?
I have a banking application that consists of a login screen, and a member section. So when a user goes to my site he will be presented with a login screen. After login in he will be redirected to the member section that he can do his whatever banking needs.
So, how to set different layouts for the login screen and the pages inside the member section? Symfony seems to use frontend/templates/layout.php
as the template for ALL pages. Is it possible to define different layouts?
-
Yes, you can define separate layouts per view (or disable the layout altogether). To do this, you must create (or edit, if you already have it) the view.yml file in the /config directory of your module. You can define the layout to be used for all views of the module or for each view separately. For example:
#in /apps/my_app/modules/my_module/config/view.yml #this will apply custom_layout to all views of the module all: layout: custom_layout #this will apply login_layout to the loginSuccess view loginSuccess: layout: login_layout #disable layout for this view homeSuccess: has_layout: false
In all cases, the layout is the file in your app's /templates directory (with .php appended). If you do not define any layout directives in the module's view configuration file, the default layout will be used.
0 comments:
Post a Comment