Search code examples
drupaldrupal-7drupal-themes

Change theme for node add page in Drupal 7


I tried using hook_custom_theme to change the theme for the node add page for a specific content type, like this, without success:

function mymodule_custom_theme() {
  if (current_path() == 'node/add/mytype')
    return 'anothertheme';
}

I know the function is running, and I know the comparison is returning TRUE. Why is it not working?


Solution

  • 1) Do you use the correct machine name for the theme?

    2) Are you sure that there are not other modules to override this later?

    3) Is the page cached? If so this may not work properly.

    Same question and discussion here: https://drupal.stackexchange.com/questions/812/how-do-i-change-a-theme-based-on-the-url

    Useful modules:Page Theme, Context, ThemeKey.