In this article I'll discuss about how to change theme of Magento in runtime, that means your system work on many themes. So lets start. According to me there is two possible way to do this.
Step: 1
Write below code in action to set Package and theme for the action
[php]
Mage::getDesign()->setArea('frontend') //Area (frontend/adminhtml)
->setPackageName('default') //Name of Your Package
->setTheme('modern'); // Name of Your theme
[/php]
Step: 2
Overwrite Mage_Core_Model_Design in file.
For this you have to make custom module.
[html]<models>
<core>
<rewrite>
<design>YourPackagename_YourModulename_Model_Design</design>
</rewrite>
</core>
</models>[/html]
Modify loadChange method as required, I just place an example of that, see below.
[php]
public function loadChange($storeId, $date = null)
{
$result = $this->getResource()
->loadChange($storeId, $date);
if (!empty($result)) {
if (!empty($result['design'])) {
$tmp = explode('/', $result['design']);
$result['package'] = $tmp[0];
$result['theme'] = $tmp[1];
}
$this->setData($result);
}
// your custom code goes here
// your custom condition
if(true) {
$result['package'] = 'default';
$result['theme'] = 'modern';
$this->setData($result);
}
return $this;
}
[/php]
Enjoy.........