If I want to us the listed API functions in the README file in another module, how do I go about calling them? In particular, the popup() function.

if(module_exists('popup') && function_exists('popup'))

evaluates false when module is enabled.

Comments

r.aubin’s picture

It looks like the popup.api.inc file isn't loaded by default. It's very confusing that the README.txt file consists almost entirely of API documentation, but yet the API functions don't appear to be available without including the file in your own code.

eL’s picture

same problem for submodules like popup-filter. In 3.0 it works fine, but now, functions are not available...

rogerb’s picture

Title: Using API function » Using API functions

Yes, the api documentation would be improved with the addition of some examples.

Here is a really basic popup.

require_once drupal_get_path('module', 'popup') . '/includes/popup.api.inc';
$text = "<p>Now is the Winter of Our discontent, made glorious Summer by this sun of York.</p>";
echo popup(array('text' => $text, 'title' => 'Richard III'));
Scheepers de Bruin’s picture

Thanks Roger.

Rather use:

module_load_include('inc', 'popup', includes/popup.api');

(and I added an example to the readme)

AlexanderPop’s picture

module_load_include('inc', 'popup', 'includes/popup.api');

is right way

Scheepers de Bruin’s picture

Status: Active » Fixed

Thanks, added on the module homepage

Scheepers de Bruin’s picture

Status: Fixed » Closed (fixed)