I have a use case wherein I need to switch to the Bartik theme when the user requests for the '/about' page on my website. This is what I have tried so far:

Approach one:


function mymodulename_custom_theme()
{
  if (arg(0) == 'about')
  {
    return 'bartik';
  }
}

Approach two:

$items['about'] = array(
   'page callback' => 'foo_bar',
   'theme callback' => 'porto_theme_callback',
);


function porto_theme_callback() {
  return 'bartik';
}

However, neither of the above two approaches seem to be working. I have enabled the bartik theme, and have tried clearing caches as well. Any help would be highly appreciated!

Comments

Jaypan’s picture

Assuming the /about page is a node, you want:

function mymodulename_custom_theme() {
  if (current_path() == 'node/10') // use the actual NID here{
    return 'bartik';
  }
  // For paths that start with /some_key/...
  elseif (arg(0, current_path()) == 'some_key') {
    return 'some_other_theme_machine_name';
  }
}
leeuwnhawk’s picture

This worked just fine. Thanks!

yelvington’s picture