Lightbox2 - How to display Drupal messages in a lightbox

Last modified: April 12, 2009 - 02:53

By placing the code below in your theme's page.tpl.php file, it's possible to have Drupal messages appear as modal popups. Just add the following code:

  <?php if ($show_messages && $messages): ?>
  <div id="lightboxAutoModal" style="display: none;" ><?php print $messages; ?></div>
  <?php endif; ?>

You can control the size of the lightbox window, either via the configuration form at admin/settings/lightbox2/html_content - this is a global property which will affect the default size of all modal windows, or by adding a rel attribute like:

<div id="lightboxAutoModal" rel="lightmodal[|height: 50px;]" style="display: none;" ><?php print $messages; ?></div>

You could expand on this to show other types of information that is available in the theme layer too.

 
 

Drupal is a registered trademark of Dries Buytaert.