function colorbox_handler_field_colorbox::render in Colorbox 6
Same name and namespace in other branches
- 7.2 views/colorbox_handler_field_colorbox.inc \colorbox_handler_field_colorbox::render()
- 7 views/colorbox_handler_field_colorbox.inc \colorbox_handler_field_colorbox::render()
Render the trigger field and its linked popup information.
File
- views/
colorbox_handler_field_colorbox.inc, line 120 - Views handlers for Colorbox module.
Class
- colorbox_handler_field_colorbox
- A handler to provide a field that is completely custom by the administrator.
Code
function render($values) {
// Load the necessary js file for Colorbox activation.
if (_colorbox_active() && !variable_get('colorbox_inline', 0)) {
drupal_add_js(drupal_get_path('module', 'colorbox') . '/js/colorbox_inline.js');
}
// We need to have multiple unique IDs, one for each record.
static $i = 0;
// Return nothing if no trigger filed is selected.
if (empty($this->options['trigger_field'])) {
return;
}
// 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);
$width = $this->options['width'] ? $this->options['width'] : '600px';
$height = $this->options['height'] ? $this->options['height'] : '400px';
$gallery_id = !empty($this->options['custom_gid']) ? $this->options['custom_gid'] : ($this->options['gid'] ? 'gallery-' . $this->view->name : '');
$link_text = $tokens["[{$this->options['trigger_field']}]"];
$i++;
$link_tag = l($link_text, '', array(
'html' => TRUE,
'fragment' => 'colorbox-inline-' . $i,
'query' => 'width=' . $width . '&height=' . $height . '&title=' . $caption . '&inline=true',
'attributes' => array(
'class' => 'colorbox-inline',
'rel' => $gallery_id,
),
));
// The outside div is there to hide all of the divs because if the specific Colorbox
// div is hidden it won't show up as a Colorbox.
return $link_tag . '<div style="display: none;"><div id="colorbox-inline-' . $i . '">' . $popup . '</div></div>';
}