Is there anyway to open a overlay with a node content using drupal overlay core module? If I could reuse at least the javascript code I'd already be happy =)
3 Answers
The faster way is to implement hook_admin_paths_alter() in a module to redefine which of the menu items defined in hook_menu()
by other modules are administrative paths.
The value returned from the implementations of hook_admin_paths(), which are then altered from the implementations of hook_admin_paths_alter()
, are used from the Overlay module to decide which pages are rendered as overlay. As other modules could use the same information to render the pages using a different theme, the module should require the Overlay module as dependency, to be sure the additional pages are effectively rendered as overlay.
function mymodule_admin_paths_alter(&$paths) {
$paths['node/*/view'] = TRUE;
}
If you notice that this implementation doesn't work when the users are viewing, for example,example.com/node/1, but only when they are viewing example.com/node/1/view, then I would implement the hook using the following code. The first implementation I provided should work, as the "View" tab is the default one, and when users are viewing example.com/node/1, Drupal is really showing example.com/node/1/view.
function mymodule_admin_paths_alter(&$paths) {
$paths['node/*'] = TRUE;
$paths['node/*/view'] = TRUE;
}
As the first line could catch all the node pages (I didn't verify that), I would verify if there are other pages under that path that should not be rendered; in that case the implementation can be changed as the following one ("node/*/backlinks" is only an example):
function mymodule_admin_paths_alter(&$paths) {
$paths['node/*'] = TRUE;
$paths['node/*/view'] = TRUE;
$paths['node/*/backlinks'] = FALSE;
}
- Normally, modules implement
hook_admin_paths()
to report which of their menu items are administrative pages; this means that if a page is not an administrative page, an entry for that page is not added to the returned array. hook_admin_paths()
is implemented for the menu items defined in your own module; to redefine when menu items defined from other modules are administrative pages, you need to implementhook_admin_paths_alter()
.- To the pages that are defined as administrative pages is not automatically applied an access control; this means that the module defining those menu items that are reported to be administrative pages still need to use "access callback" and "access arguments" to define which users can access those menu items associated with administrative pages. Pages defined as administrative pages are only rendered differently, if there is a module that does that.
- The node module defines the node editing pages as administrative page only when a checkbox in an administrative page is selected; those pages are already handled.
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.
I ended up using the Overlay Paths module with Panels so I could show our newsletter signup form. The form showed up, but it also included everything else on the page (header, footer, sidebars, etc.). It was displaying the newsletter signup page through the default site template.
So the tricky solution was to create a Variant on the default site template under Panels. The Variant was selected only if the Node:Type was a Webform. Then I removed the excess content and made the Variant display only the Main Content.
Presto! The newsletter signup page appeared in an overlay simply as a form that I could style to my CSS heart's content!