Hello,

I am working on integrating the ADMIN module and the Rubik theme with the Modal Frame API and Node Relationships Modules. The problem I am having is once the admin validation line is added to the page template it injects the admin menu and all of the resources (css js) on any page load.

The Modal Frame module strips out the regions and displays nodes, views, and system screens in a modal dialog. My goal is to either check against a state when a modal frame content is loaded or add an override in the pre-processors for the ADMIN module to stop the inclusion of the admin menu in certain instances.

My question is which methods should I start reviewing to accomplish this?

If you are interested here is the issue I am working on to integrate everything together. (http://drupal.org/node/672970)

Comments

emptyvoid’s picture

Title: ADMIN Menu displayed in Modial Frame API » ADMIN Menu displayed in Modal Frame API

sorry fixing a spelling mistake in the title of the post.

emptyvoid’s picture

Version: 6.x-2.0-alpha3 » 6.x-2.x-dev
Category: support » bug
markus_petrux’s picture

Title: Provide a method to disable the output of the toolbar programmatically » ADMIN Menu displayed in Modal Frame API

Maybe the admin module could provide a method to disable the output of the toolbar programmatically. For example, the admin_menu module implements hook_suppress() that can be invoked from other modules to suppress the admin_menu output like this:

  // Disable admin_menu, which is something child windows don't need.
  module_invoke('admin_menu', 'suppress');

Snippet from the Modal Frame API.

So... if admin module could provide something similar, I could use it from Modal Frame API to ensure the admin toolbar is not rendered in modal frames.

markus_petrux’s picture

Title: ADMIN Menu displayed in Modal Frame API » Provide a method to disable the output of the toolbar programmatically
Category: bug » feature

Better title.

markus_petrux’s picture

For example, admin module could include this:

/**
 * Suppress display of administration toolbar.
 *
 * This function should be called from within another module's page callback
 * (preferably using module_invoke()) when the menu should not be displayed.
 * This is useful for modules that implement popup pages or other special
 * pages where the menu would be distracting or break the layout.
 *
 * @param $set
 *   Defaults to TRUE. If called before hook_footer(), the menu will not be
 *   displayed. If FALSE is passed, the suppression state is returned.
 */
function admin_suppress($set = TRUE) {
  static $suppress = FALSE;
  if (!empty($set) && $suppress === FALSE) {
    $suppress = TRUE;
  }
  return $suppress;
}

And then, maybe check the suppress flag in admin_preprocess_page() by patching this function like this:

 /**
  * Implementation of hook_preprocess_page().
  */
 function admin_preprocess_page(&$vars) {
   $vars['admin'] = '';
-  if (admin_is_enabled('admin menu')) {
+  if (!admin_suppress(FALSE) && admin_is_enabled('admin menu')) {
     $links = admin_menu_tree();
     $links = theme('admin_toolbar', $links);
     $vars['admin'] = $links;
   }
 }
ludo1960’s picture

Title: ADMIN Menu displayed in Modal Frame API » Provide a method to disable the output of the toolbar programmatically

Shouldn't that be:

module_invoke('admin_menu', 'suppress', TRUE);

to hide the menu ?

markus_petrux’s picture

TRUE is default. :)

ludo1960’s picture

Hmmm,

I tried without TRUE and it didn't work!

markus_petrux’s picture

I have edited comment #5 with a few changes. The idea is based on how admin_menu does this stuff. However, I do not use admin module myself, and I have just browsed the code. So this might need more love.

ludo1960’s picture

Love is all you need! (Lennon, McCartney)

markus_petrux’s picture

Yep!

Well, let's see if admin module maintainers agree on such an approach. Once they do, I would be glad to implement whatever is done here from Modal Frame API.

yhahn’s picture

Status: Active » Fixed

Thank you. I've committed the change here: http://drupal.org/cvs?commit=328052

Note that the way these suppress hooks have been written (as well as admin_menu()) allow for you to simply call module_invoke_all('suppress') instead of each module's hook individually.

Status: Fixed » Closed (fixed)

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

realityloop’s picture

For the benefit of others that may be trying to figure this out to call it for admin you use the following:

module_invoke('admin', 'suppress');

for admin menu:
module_invoke('admin_menu', 'suppress');