You are here

function lightbox2_handler_field_lightbox2::render in Lightbox2 6

Same name and namespace in other branches
  1. 8 lightbox2_handler_field_lightbox2.inc \lightbox2_handler_field_lightbox2::render()
  2. 7.2 lightbox2_handler_field_lightbox2.inc \lightbox2_handler_field_lightbox2::render()
  3. 7 lightbox2_handler_field_lightbox2.inc \lightbox2_handler_field_lightbox2::render()

Render the trigger field and its linked popup information.

File

./lightbox2_handler_field_lightbox2.inc, line 115

Class

lightbox2_handler_field_lightbox2
A handler to provide a field that is completely custom by the administrator.

Code

function render($values) {

  // We need to have multiple unique IDs, one for each record.
  static $i = 0;
  static $link;
  if (!empty($this->options['trigger_field'])) {

    // We don't actually use the link, but we need it there for lightbox to function.
    if (empty($link)) {

      // Get the path name.
      $path = isset($_GET['q']) ? $_GET['q'] : '<front>';
      $link = url($path, array(
        'absolute' => TRUE,
      ));
    }

    // Get the token information and generate the value for the popup and the
    // caption.
    $tokens = $this
      ->get_render_tokens($this->options['alter']);
    $popup = filter_xss_admin($this->options['popup']);
    $caption = filter_xss_admin($this->options['caption']);
    $popup = strtr($popup, $tokens);
    $caption = strtr($caption, $tokens);
    $i++;

    // The outside div is there to hide all of the divs because if the specific lightbox
    // div is hidden it won't show up as a lightbox.  We also specify a group
    // in the rel attribute in order to link the whole View together for paging.
    $group_name = !empty($this->options['custom_group']) ? $this->options['custom_group'] : ($this->options['rel_group'] ? 'lightbox-popup-' . $this->view->name . '-' . implode('/', $this->view->args) : '');
    return "<a href='{$link} #lightbox-popup-{$i}'  rel='lightmodal[{$group_name}|width:" . ($this->options['width'] ? $this->options['width'] : '600px') . ';height:' . ($this->options['height'] ? $this->options['height'] : '600px') . "][" . $caption . "]'>" . $tokens["[{$this->options['trigger_field']}]"] . "</a>\n                <div style='display: none;'><div id='lightbox-popup-{$i}' class='lightbox-popup'>{$popup}</div></div>";
  }
  else {
    return;
  }
}