You are here

function popup in Popup 7

Same name and namespace in other branches
  1. 8 includes/popup.api.inc \popup()
  2. 7.x includes/popup.api.inc \popup()
  3. 6.x includes/popup.api.inc \popup()

Renders a popup element using specified attributes. This method should be used to create popups programmatically.

Parameters

array $attributes:

Attributes is a keyed array where the key is the attribute name. Acceptible content related attributes are:

text - Actual text to display within the popup body.

node - Nid of the node to be displayed within the popup body. Additional options for the node display are:

teaser-display - set to TRUE the node will be rendered as a teaser.

form - form id of the form to be displayed within the popup block.

args - a comma separated list of arguments to be passed to the form.

block - Id of the block to be popped up OR a value of TRUE, indicating that a block provided by a module should be displayed. In the latter case, the following attributes should also be provided:

module - the name of the module that provides the block. delta - the delta of the module block.

menu - Machine name of the menu to be popped up. Note that the menu module prefixes some menu ids with "menu-". Additional attributes for menus are:

flat - set to TRUE exposes the top level children of the menu, while its root is not rendered. inline - causes the top level children to be displayed next to eachother, rather than below.

view - Machine name of the view to be popped up. The following attributes may be provided for views:

display - the menu display to be rendered. Defaults to the Default display. args - a comma separated list of arguments to be passed to the view.

php - A string of php that returns rendered text to be displayed within the popup body.

image - A path relative to the drupal root to an image to be used as the popup title.

title - The title that should be used for the popup. This will override any of the automatically generated titles provided by each of the above popup types. If an image is provided, this will be used as the alt attribute.

link - The URL to assign to the anchor of the popup. Note that this attribute will have no effect if activate is set to click, and Javascript is enabled within the client browser. It is still recommended to provide one to degrade semi-gracefully.

Display related attributes:

id - The CSS id, prefixed with "popup-element-id-", that will be assigned to the wrapper of the entire popup element. Note that the body will be wrapped within an element with "-active" appended to the id, and class "popup-element-wrapper", before being appended to the "popup-active-overlay" at the end of the HTML body.

class - The CSS class, prefixed with "class-" that will be assigned to the wrapper of the entire popup element, as well as the wrapper of the body. See above.

origin - The corner of the title that the popup will originate at. Acceptable values:

top-left, top-right, bottom-left and bottom-right

expand - The direction in which the popup should expand. Acceptible values:

top-left, top-right, bottom-left and bottom-right

effect - The name of the showing/hiding animation effect to use. Modules may provide their own effects by implementing hook_popup_effects. The popup suite provides these effects:

default - show or hide the popup with no animation. fade - fades the popup in or out. slide-down - slides the popup up/down. slide-down-fade - a combination of both of the above.

style - The visual style to be used to display this popup item.

format - Predefined popup format as managed by the popup_ui module.

width - Displayed width of the popup body inner in pixels.

Behaviour related attributes:

activate - How the popup should be activated. Accepted values:

click - users must click on the popup title to reveal the body. hover - (Default) users activate popups by hovering over the popup title.

ajax - Causes the body of the popup to be retrieved with an AJAX call only when the body is to be shown to the user. This attribute applies to nodes, blocks, forms, views and php only.

ajax_extra - a string tag that will be appended as a last argument of the ajax request url.

close - Provides a close button within the popup body. Only applies to click activated popups.

empty-body - How an empty body should be handled. Accepted values:

all - show the popup with an empty body. title - just show the popup title, default. none - show nothing.

5 calls to popup()
popup_filter_process_tag in modules/popup_filter/includes/popup_filter.processing.inc
Processes a popup tag
popup_menu_block_view in modules/popup_menu/popup_menu.module
Implementation of hook_block_view
popup_nodereference_field_formatter_view in modules/popup_nodereference/popup_nodereference.module
Implementation of hook_field_formatter_view
popup_test_ajax in modules/popup_test/includes/popup_test.pages.inc
Popup test AJAX content page
popup_test_content in modules/popup_test/includes/popup_test.pages.inc
Popup test content page
30 string references to 'popup'
popupformat_features_export in modules/popup_ui/includes/popup_ui.features.inc
Implementation of [component]_features_export()
popupformat_features_export_options in modules/popup_ui/includes/popup_ui.features.inc
Implementation of [component]_features_export()
popup_admin_settings in includes/popup.admin.inc
Popup administration settings form
popup_block_preprocess_block in modules/popup_block/popup_block.module
popup_descriptions_preprocess_form_element in modules/popup_descriptions/popup_descriptions.module
Implementation of hook_preprocess_form_element

... See full list

File

includes/popup.api.inc, line 137

Code

function popup($attributes) {
  module_load_include('inc', 'popup', 'includes/popup.util');
  drupal_alter('popup_attributes', $attributes);
  $attributes['altered'] = TRUE;
  $type = @array_shift(array_intersect(array(
    'text',
    'node',
    'block',
    'form',
    'php',
    'menu',
    'view',
  ), array_keys($attributes)));
  $function = '_popup_' . $type;
  $keys = array_keys($attributes);
  $intersect = array_intersect(array(
    'node',
    'block',
    'form',
    'view',
    'php',
  ), $keys);
  $ajax_type = @array_shift($intersect);

  // If AJAX is to be used to populate the body, don't generate it now
  if (isset($attributes['ajax']) && $attributes['ajax'] && $ajax_type && function_exists($function)) {
    return popup_element($function($attributes, 'title'), 'none', $attributes);
  }
  if (function_exists($function)) {
    return $function($attributes);
  }
}