This module gives Drupal the ability to easily change links into popup dialog boxes.
IMPORTANT NOTE: it only works with themes that have selectable content areas. To use with Garland, you must edit
themes/garland/page.tpl.php, and change line 75 from to
LIMITATIONS: Does not work with tinymce. Unlikely to work with other WYSIWYG's.
There are a couple of ways to use this module.
#1) Attach popup behavior to a link with popups_add_popups call.
// In your code
popups_add_popups(array('#mylink', '#mylink2=>array('width'=>'200px')));
This is the simplest method, especially if you want to pass in per-link options.
#2) Add the popup class to an existing link (you still must make sure popups_add_popups() is called
sometime for the page).
Example in code:
popups_add_popups();
$output .= l("Pop up entire local page.", 'popups/test/response', array('class' => 'popups')) ."
";
class="popups" requests an informational popup.
class="popups-form" requests a popup with a form that modifies the content of the original page.
And you can use the pseudo-attribute, "on-popups-options" to send options, if you don't mind having non-validating HTML.
The advantage to this attribute, is that it will be removed from user content by the HTML filter.
Example:
print l("Pop with options (width=200px).", 'popups/test/response',
array('class' => 'popups', 'on-popups-options' => '{width: "200px"}'))
See _popups_test_popups() for more examples.
#3) You can add a custom module that implements the hook_popups hook.
hook_popups returns an array of popup rules, keyed by the id
of a form, or the url of a page.
Each rule is an array of options, keyed by a jQuery selector.
Leaving off the options array is equal to a link with class="popup-form".
Rule Format Example:
'admin/content/taxonomy' => array( // Act only on the links on this page.
'div#tabs-wrapper a:eq(1)', // No options, so use defaults. Note: Selector must select element(s).
'table td:nth-child(2) a' => array(
'noReload' => true, // Popup will not modify original page.
),
)
Options:
noReload: If this is true, the popup will leave the original page unmodified (Default: false).
forceReturn: url to force a stop to work flow (only use in conjunction with noReload).
href: override the href in the a element, or attach an href to a non-link element.
width: override the width specified in the css.
targetSelectors: array (or hash) of jQuery selectors, which override what content should be swapped in from the new page.
titleSelectors: array of jQuery selectors that say where to put the new title.
[These can be called from the hook or popups_add_popups, but not with the on-popups-options attribute]
additionalJavascript: Array of JavaScript files that must be included to correctly run the page in the popup.
additionalCss: Array of CSS files that must be included to correctly style the page in the popup.
behaviors(Drupal 5): Array of functions to call on the Popup's html. ex: array("Drupal.popups.collapsibleBehavior")