Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programatically disable regions on a drupal 7 page?

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 ?

like image 273
redben Avatar asked Dec 08 '25 10:12

redben


2 Answers

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.

like image 70
user1984707 Avatar answered Dec 10 '25 08:12

user1984707


You can create a an extra page.tpl.php specifically for the page where you want to hide the regions. The naming principle is similar to the one for nodes.

Let's say you have a page with the url example.com/content/contact. A template named page--content--contact.tpl.php would serve that page and any page that starts with that url, i.e. the page example.com/content/contact/staff would also use that template (I think).

Check the classes of the body element for clues to what you can name your template, most themes will print that. In my example above, the body element would include the class page-content-contact.

like image 31
angelika Avatar answered Dec 10 '25 08:12

angelika



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!