====== Symfony YAML Configuration Reference ====== =====The view.yml configuration file===== In this article we assume that you are familiar with [[http://www.symfony-project.org/reference/1_4/en/02-YAML|The YAML Format]] and [[http://www.symfony-project.org/reference/1_4/en/03-Configuration-Files-Principles|Configuration File Principles]]. The //view.yml// configuration file can be used to configure the View layer. When an application is created, symfony generates a default view.yml file in the application //config/// directory which configures the view for the whole application (under the //default// key). The default view configuration can be overridden for a module by creating a //view.yml// file in the //config/// directory of the module. view_name: has_layout: layout: layout_name http_metas: list_of_http_metas metas: list_of_metas stylesheets: [-*, css_file1, css_file2, ...] javascripts: [js_file1, js_file2, ...] =====View configuration options===== ====view_name==== If //view.yml// is in the //config/// directory of the module, then //view_name// key can specify one of the following: * The view (template) name to configure only specific module template (eg.: //indexSuccess//); * The //'All'// keyword for whole module. If //view.yml// is in the application //config/// directory which describes the view settings for the whole application, //view_name// key must be set to //'default'//. Eg.: default: http_metas: ... metas: ... ====view_name > has_layout==== Specifies whether or not to enable the page decoration with layout. The layout is automatically disabled for XML HTTP requests and non-HTML content types, unless explicitly set for the view. Possible values: //// Default: //true// ====view_name > layout==== Defines the default layout used by the application. By default, symfony decorates every page with the //layout.php// file, found in the application //templates/// directory. You can also set a layout in the model actions class, eg: class modelActions extends sfActions { public function executeIndex(sfWebRequest $request) { $this->setLayout('new_layout'); // set new layout $this->setLayout(false); // disable layout $this->setLayout(null); // revert the layout to the one in the view.yml } } Default: //layout// ====view_name > http_metas==== Defines http //meta// tags to be included in the layout. For example: default: http_metas: content-type: text/html The inclusion of the http meta tags defined in //view.yml// can be done manually with the //include_http_metas()// helper. Note that it is preferred to add meta tags directly to the layout for static metas (like the content type), or use a slot for dynamic metas (like the title or the description). ====view_name > metas==== Defines //meta// tags to be included in the layout. For example: default: metas: title: symfony project description: symfony project keywords: symfony, project language: en robots: index, follow The inclusion of the meta tags defined in //view.yml// can be done manually with the //include_metas()// helper. Note that it is preferred to add meta tags directly to the layout for static metas (like the content type), or use a slot for dynamic metas (like the title or the description). ==== stylesheets ==== ** view_name > stylesheets ** Defines an array of stylesheets to use for the current view. Symfony includes files in the same order as they are defined. You can also omit the .css suffix and change the media attribute: stylesheets: [main, style1.css, style2.css, print.css: { media: print }] For removing, previous css: stylesheets: [-*] Note that it is preferred to use //use_stylesheet()// helper instead of //stylesheets// setting: Default: //[main.css]// ==== javascripts ==== ** view_name > javascripts ** Defines an array of JavaScript files to use for the current view. Symfony includes files in the same order as they are defined. You can also omit the .js suffix: javascripts: [script1, script2.js] Note that it is preferred to use //use_javascript()// helper instead of //javascripts// setting: