function lightbox2_handler_field_lightbox2::render in Lightbox2 8
Same name in this branch
- 8 lightbox2_handler_field_lightbox2.inc \lightbox2_handler_field_lightbox2::render()
- 8 src/lightbox2_handler_field_lightbox2.php \Drupal\lightbox2\lightbox2_handler_field_lightbox2::render()
Same name and namespace in other branches
- 6 lightbox2_handler_field_lightbox2.inc \lightbox2_handler_field_lightbox2::render()
- 7.2 lightbox2_handler_field_lightbox2.inc \lightbox2_handler_field_lightbox2::render()
- 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 116 - Contain the integration with views A handler to provide a field that is completely custom by the administrator.
Class
- lightbox2_handler_field_lightbox2
- @file Contain the integration with views 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 = \Drupal\Component\Utility\Xss::filterAdmin($this->options['popup']);
$caption = \Drupal\Component\Utility\Xss::filterAdmin($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;
}
}