Developers

License

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

The layout can exist in the templates directory of your application or in
the templates directory of any plugin. This means that your entire
theme can live inside a plugin and be repackaged for other projects.

A few other, optional, configuration variables exist for a theme. See the
config/app.yml packaged with the plugin for full examples.

Setting Themes

Once you've created a theme or themes, you'll want to instruct your application
to use those themes. By default, the plugin won't start using themes until
you tell it to. So, you can apply theming selectively without affecting
the rest of your application.

Themes can be attached in many different ways:

Using a global theme

Very commonly, you'll want to use one theme for your entire application.
This basically replaces the use of view.yml to define the layout,
stylesheets, and javascripts for your application. Defining a default
theme is easy:

all:
theme:
controller_options:
default_theme: new_design

By doing this, the new_design theme will be used globally in your application.

Setting a theme in the action

The global default theme can easily be overridden in any action. For example,
suppose that you still need to use the old_design theme for a particular action:

This method is the "strongest" method of setting a theme and will override
all other methods.

Setting a theme for a module

Alternatively, themes can be set on a module-by-module basis. Once again,
this will override the global default theme. For example, suppose the module
old_module should use the theme old_design:

all:
theme:
controller_options:
modules:
old_module: old_design

Setting a theme for a route

You can even set a theme for a paricular route. This means that you could
have the same content served by two different urls, each rendering their
own theme! For example, suppose that you create a route called homepage_old,
and you want it to use the old_design theme:

all:
theme:
controller_options:
routes:
homepage_old: old_design

Switching themes based on a url parameter ?sf_theme=

By default (this can be turned off), you can switch to any available theme
by appending ?sf_theme=theme_name to the end of any url.

This will set a user attribute so that you can browse your entire site
with this theme. To clar the user attribute, simply append ?sf_theme=clear
to the end of your url.

Advanced theming using an event

If you need to be more specific in your theming, you can easily do this
by connecting to the theme.set_theme_from_request event. For example,
suppose you want to use a different theme for users with the fr culture.
In your application configuration file (apps/app_name/config/app_nameConfiguration.class.php):