How to programatically disable regions on a drupal 7 page?

redben picture redben · Apr 13, 2011 · Viewed 8.5k times · Source

I am working on a module where i have a page that must have no regions or extra content. A kind of "please wait" page.
How do i diable all extra content (regions menus...etc) ? i think Panels has this ability but i can't find the snippet it uses.
On another hand is it possible for a module to specify a special custom page ? like the maintenance-page for example ?

Answer

user1984707 picture user1984707 · Jan 16, 2013

The page.tpl.php method is not flexible. It is based on a presentation logic. You should use hook_page_alter() for a business logic solution. For example:

function yourmodulename_page_alter(&$page) {
  if (current_path() == 'node/add/yourcontenttype') {
    unset($page['sidebar_first']);
  }
}

Also look at very powefull Context module.