I have a symfony 1.4 project with the single application frontend. This application has the single module book with the single action index.
I have two templates for the index action: indexSuccess.mobile.php and indexSuccess.html.php. The action will set the format so as to call one or the other of these templates.
I want to use a different layout for each of these two templates: layout.mobile.php and layout.html.php. The file apps/frontend/modules/book/config/view.yml file is used to specify which layout to use as well as which CSS and JavaScript files are included in a layout.
Since there can only be one view.yml file per module, how do I configure view.yml so that indexSuccess.mobile.php uses layout.mobile.php and loads the appropriate CSS and JS files, while indexSuccess.html.php uses layout.html.php and loads its appropriate CSS and JS files?
I want to use layouts since I will eventually add many more actions/templates to this module.
You can use the
setLayout()method of your action to achieve this.UPDATE for the css and js files, you can also use the action (call
sfWebResponse::addStylesheet()andsfWebResponse::addJavascript()).If you absolutely want to do all this from the
view.yml, the best for you would be to change the template name (return a different suffix in your action)