Time to change skin

Hi everyone,

So about skins.. This short note is for those who wants to allow customizing of their project with themes. It’s really easier than you can thought. As a basic manual we’d recommend this snippet: (btw, there is also the other one which explains some other aspects of this stuff:

So main idea is you can use the same layout template and customize it based on defined theme.
They recommend to use the following view class to allow themes functionality:

class myView extends sfPHPView
public function configure()

// Grab the theme from the user (of from anywhere else)
$theme = $this->getContext()->getUser()->getTheme();

// If there is a theme and if the theme feature is enabled
if($theme && sfConfig::get('app_theme'))
// Look for templates in a $theme/ subdirectory of the usual template location
if (is_readable($this->getDirectory().'/'.$theme.'/'.$this->getTemplate()))

// Look for a layout in a $theme/ subdirectory of the usual layout location
if (is_readable($this->getDecoratorDirectory().'/'.$theme.'/'.$this->getDecoratorTemplate()))


Well, if you still use symfony 1.0 this can be also good way to allow visitors to see your site in different formats (i.e. you can use themes to show content in different formats just via overriding main theme or layout). symfony 1.1 supports another way to allow accessing site in different formats so there is no need in such class.

2 replies on “Time to change skin”

Leave a Reply

Your email address will not be published. Required fields are marked *