The view.yml Configuration File
The View layer can be configured by editing the ~view.yml
~ configuration file.
As discussed in the introduction, the view.yml
file benefits from the configuration cascade mechanism, and can include constants.
This configuration file is mostly deprecated in favors of helpers used directly in the templates or methods called from actions.
The view.yml
configuration file contains a list of view configurations:
---
VIEW_NAME_1:
# configuration
VIEW_NAME_2:
# configuration
# ...
The
view.yml
configuration file is cached as a PHP file; the process is automatically managed by the ~sfViewConfigHandler
~ class.
Layout
Default configuration:
---
default:
has_layout: true
layout: layout
The view.yml
configuration file defines the default ~layout~ used by the application. By default, the name is layout
, and so symfony decorates every page with the layout.php
file, found in the application templates/
directory. You can also disable the decoration process altogether by setting the ~has_layout~
entry to false
.
The layout is automatically disabled for XML HTTP requests and non-HTML content types, unless explicitly set for the view.
Stylesheets
Default Configuration:
---
default:
stylesheets: [main.css]
The stylesheets
entry defines an array of stylesheets to use for the current view.
The inclusion of the stylesheets defined in
view.yml
can be done with theinclude_stylesheets()
helper.
If many files are defined, symfony will include them in the same order as the definition:
---
stylesheets: [main.css, foo.css, bar.css]
You can also change the media
attribute or omit the .css
suffix:
This setting is deprecated in favor of the use_stylesheet()
helper:
<?php use_stylesheet('main.css') ?>
In the default
view.yml
configuration file, the referenced file ismain.css
, and not/css/main.css
. As a matter of fact, both definitions are equivalent as symfony prefixes relative paths with/css/
.
JavaScripts
Default Configuration:
---
default:
javascripts: []
The javascripts
entry defines an array of JavaScript files to use for the current view.
The inclusion of the JavaScript files defined in
view.yml
can be done with theinclude_javascripts()
helper.
If many files are defined, symfony will include them in the same order as the definition:
---
javascripts: [foo.js, bar.js]
You can also omit the .js
suffix:
---
javascripts: [foo, bar]
This setting is deprecated in favor of the use_javascript()
helper:
<?php use_javascript('foo.js') ?>
When using relative paths, like
foo.js
, symfony prefixes them with/js/
.
Metas and HTTP Metas
Default Configuration:
---
default:
http_metas:
content-type: text/html
metas:
#title: symfony project
#description: symfony project
#keywords: symfony, project
#language: en
#robots: index, follow
The http_metas
and metas
settings allows the definition of meta tags to be included in the layout.
The inclusion of the meta tags defined in
view.yml
can be done manually with theinclude_metas()
andinclude_http_metas()
helpers.
These settings are deprecated in favor of pure HTML in the layout for static metas (like the content type), or in favor of a slot for dynamic metas (like the title or the description).
When it makes sense, the
content-type
HTTP meta is automatically modified to include the charset defined in thesettings.yml
configuration file if not already present.
インデックス
Document Index
関連ページリスト
Related Pages
Introduction
The YAML Format
Configuration File Principles
The settings.yml Configuration File
The factories.yml Configuration File
The generator.yml Configuration File
The databases.yml Configuration File
The security.yml Configuration File
The cache.yml Configuration File
The routing.yml Configuration File
The app.yml Configuration File
The filters.yml Configuration File
The view.yml Configuration File
Other Configuration Files
Events
Tasks
Appendix A - License

日本語ドキュメント
Japanese Documents
2011/01/18 Chapter 17 - Extending Symfony
2011/01/18 The generator.yml Configuration File
2011/01/18 Les tâches
2011/01/18 Emails
2010/11/26 blogチュートリアル(8) ビューの作成

