Two methods for Drupal Overlay to apply to a specified page

Source: Internet
Author: User
Tags drupal

 

Method 1 add to admin_paths

It should be said that this method is the fastest. In a module, redefine the menu items defined in hook_menu to hook_admin_paths_alter. The paths belong to admin_path, which is used to determine which pages will be rendered as Overlay layers. The Overlay module must be dependent on other pages to ensure effective Overlay rendering.

You can use pages defined by other modules as management pages.

The code is as follows: Copy code

Function mymodule_admin_paths_alter (& $ paths ){
$ Path ['node/* '] = TRUE;
$ Path ['node/*/view'] = TRUE;
$ Path ['node/*/backlinks '] = FALSE;
}

Generally, each module implements hook_admin_paths () to set their custom menu items to manage pages. This means that a webpage is not a management page, the path of the page is not added to the returned array.

Hook_admin_paths () is the execution of menu items defined in your module. When you redefine the menu items defined in other modules, you need to use hook_admin_paths_alter () for implementation.

That is, whether the page defined in the current module is a management page:

The code is as follows: Copy code

Function hook_admin_paths (){
$ Paths = array (
'Mymodule/*/add' => TRUE,
'Mymodule/*/edit' => TRUE,
);
Return $ paths;
}

Method 2 use Overlay Paths
You can also use the Overlay Paths module. It is a simple module. Allows administrators to use non-management pages to Overlay layers. This means that you can reuse Overlay as a pop-up window without adding more JavaScript libraries to your website to implement similar Modal functions.


You can use the APIs defined by Overlay Paths as the hooks to achieve the following:

The code is as follows: Copy code

/**
* Implement hook_overlay_paths ().
*/
Function mymodule_overlay_paths (){
$ Paths = array (
'User' => TRUE,
);
Return $ paths;
}

In this way, you can use the Overlay provided by Drupal to implement the pop-up window of the website. Please try it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.