Reputation: 7825
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.
Upvotes: 2
Views: 3699
Reputation: 6814
I may be very late to answer this one, but thought it may help someone, due to their hard luck if they are asked to work on these legacy version such as symfony 1.4, like me.
You can able to specify the layout file per action. So the solution is to place the layout and my_layout in the apps/frontend/templates
directory and define the layout configuration inside apps/frontend/modules/book/config/view.yml
like following:
indexSuccess:
layout: my_layout
mobileSuccess:
layout: layout
For more information, Please check "Layout Configuration" in this link
Upvotes: 0
Reputation: 4881
I didn't tested, but seems like it does the trick:
<?php
// in indexSuccess.mobile.php
decorate_with('layout.mobile');
Upvotes: 0
Reputation: 23255
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()
and sfWebResponse::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)
Upvotes: 5