hi!

i want to hide the admin menu for special page templates like page-nodetype.tpl.php.
how can I do that?

thanx!!!

CommentFileSizeAuthor
#1 admin_menu-HEAD.suppress.patch979 bytessun

Comments

sun’s picture

Title: hide menu for page-nodetype.tpl.php » Howto: Hide menu on certain pages
Version: 6.x-1.1 » 6.x-1.x-dev
Assigned: headkit » Unassigned
Status: Active » Needs review
StatusFileSize
new979 bytes

If you are using the latest development snapshot, then you can suppress the admin menu by simply calling the function

module_invoke('admin_menu', 'suppress');

However, this needs to happen as early as possible in the page request, so
placing it in the theming layer (resp. a page template file) is too late.
Ideally, the function is called in hook_init() in a custom module. If you do
not have a custom module, placing it into some conditional code at the top of
template.php may work out, too.

headkit’s picture

Status: Needs review » Closed (fixed)

thank you!

sun’s picture

Status: Closed (fixed) » Reviewed & tested by the community
sun’s picture

Status: Reviewed & tested by the community » Fixed

Committed to all branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

doublejosh’s picture

This link might be useful...

http://drupal.org/node/502408

Hope admin menu is moved from admin_menu_init() into admin_menu_preprocess_page() soon!
Would love to be able to add this my template...

function phptemplate_preprocess_page(&$variables) {
  if(!arg(2) && $variables['node']->field_blank_page[0]['value']=='1') {
    module_invoke('admin_menu', 'suppress');
    $variables['template_files'][] = 'page-node_blank_page';
  }
}
doublejosh’s picture

After hearing Larry's butler talk I wanted to be sure and stop using arg() in modules and this spot is a nasty example.

I was only able to make this work at the init level, and am unsure about what is *best* to test on at that point other than arg().
Is there a later hook where this would be better done? Contexts sure aren't available yet.

function my_module_init() {
    if( /* what to test for indeed!? */ ) {
	module_invoke('admin_menu', 'suppress');
    }
}
baysaa’s picture

Using

module_invoke('admin_menu', 'suppress');

in hook_preprocess_page in template.php works for me using admin_menu 3.0rc4