I am thinking of using Drupal's built-in admin overlay jQuery script to overlay my own contents. Is it possible?

5 Answers 5


The Overlay module renders as overlay the pages for which an implementation of hook_admin_paths() returns TRUE for the associated path. For example, the implementation of that hook done from the Node module is the following one:

function node_admin_paths() {
  if (variable_get('node_admin_theme')) {
    $paths = array(
      'node/*/edit' => TRUE, 
      'node/*/delete' => TRUE, 
      'node/*/revisions' => TRUE, 
      'node/*/revisions/*/revert' => TRUE, 
      'node/*/revisions/*/delete' => TRUE, 
      'node/add' => TRUE, 
      'node/add/*' => TRUE,
    return $paths;

This means that the node edit form is rendered as overlay, when the Overlay module is enabled. When the Overlay module is not enabled, then those pages are rendered using the administrative theme.

For paths implemented by other modules, a module can implement hook_admin_paths_alter(). An example of implementation could be the following one, which would make the user profile pages rendered in an overlay.

function mymodule_admin_paths_alter(&$paths) {
  // Treat all user pages as administrative.
  $paths['user'] = TRUE;
  $paths['user/*'] = TRUE;
  // Treat the forum topic node form as a non-administrative page.
  $paths['node/add/forum'] = FALSE;

You can also use the Overlay Paths module. This is a simple module that enables administrators to use the built-in Overlay for non-admin pages. This means that you can use the overlay for doing popups without adding yet more javascript libraries to your site.


If you want to implement this function for a particular content type, so that all nodes of that content type opens in the administrative overlay, you can use the following code:

 * Implements hook_admin_paths_alter().
function YOUR_MODULE_admin_paths_alter(&$paths) {
  $query = new EntityFieldQuery();
  $query->entityCondition('entity_type', 'node')
      ->entityCondition('bundle', 'YOUR_CONTENT_TYPE')
      ->propertyCondition('status', 1);
  $result = $query->execute();

  if (isset($result['node'])) {
    $nodes = array_keys($result['node']);
    foreach ($nodes as $node_id) {
      $node_path = 'node/' . $node_id;
      $paths[$node_path] = TRUE;

The Overlay module is hardcoded for a single purpose, displaying admin pages. It would require a huge amount of effort to reliably re-use that code for your own content.


Maybe one of the numerous contrib module can help you out, like Dialog API.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.