Friday, July 8, 2011

Changing Drupal(6.2) theme on the fly

Hi,

This probably will be among my shortest post. The most commonly used module in Drupal for handling theme's is the ThemeKey module. But if you face a requirement where you have to change the theme of the page on the fly, then this post will be helpful.

To change the theme on the fly, you just need to write two lines of code i.e.

global $custom_theme;
$custom_theme="my_theme_name";

That's it. That is all that you have to do to change the page theme in Drupal.


Explanation: