I need to create popups within my PHP-coded pages and am having trouble with the API (sorry, I'm a relative newbie at both PHP and Drupal). My PHP code is below, which results in exactly nothing rendered to the screen, but the rest of my page looks fine. What am I doing wrong?

require_once 'sites/all/modules/popup/includes/popup.api.inc';

$attribs['image'] = "/sites/all/images/info_g.png";
$attribs['title'] = "Click for more info";
$attribs['format'] = "Default click";
$attribs['text'] = "This is a test of the emergency broadcast system";
popup($attribs);

Comments

etelecom’s picture

Title: Popup API: Newbie requests help » Popup API: Using Popups Within PHP code
Scheepers de Bruin’s picture

Hi etelecom

Rather use:
module_load_include('inc', 'popup', 'includes/popup.api');
to include the popup API. But that's not the issue...

The call to popup(..) only returns a rendered html representation of the popup and makes sure all the correct js etc is loaded onto the page.

To get your popup to show remember to print the output:

print popup($attribs);
Scheepers de Bruin’s picture

Status: Active » Fixed
etelecom’s picture

Thank you for your prompt reply! That solved my problem.

However, I could not get the 'image' attribute to work. I had to use the title field set to <img src='path_to_image'/>. I found this "solution" in another thread (https://drupal.org/node/1804536).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.