function JuiceboxFormatterViewsStyle::render in Juicebox HTML5 Responsive Image Galleries 7.2
Render the view page display.
This is where the Juicebox embed code is built for the view.
Overrides views_plugin_style::render
File
- plugins/
JuiceboxFormatterViewsStyle.inc, line 171 - Contains the Juicebox views style plugin.
Class
- JuiceboxFormatterViewsStyle
- Style plugin to render each item in a views list.
Code
function render() {
$element = array();
$view = $this->view;
// If we are previewing the view in the admin interface all the necessary
// <script> elements in our embed markup seem to get stripped. Display
// an admin message instead in this case.
if (strpos(current_path(), 'admin/structure/views') === 0) {
drupal_set_message(t("Due to javascript requirements Juicebox galleries cannot be viewed as a live preview. Please save your view and visit the full page URL for this display to preview this gallery."), 'warning');
return $element;
}
// Generate a unique ID that can be used to identify this gallery and view
// source details.
$xml_id = 'viewsstyle/' . $view->name . '/' . $view->current_display;
foreach ($view->args as $arg) {
$xml_id .= '/' . $arg;
}
$xml_args = explode('/', $xml_id);
$xml_path = 'juicebox/xml/' . $xml_id;
// Calculate the path to edit the view (used for admin contextual links).
$context = array();
$context['conf_path'] = 'admin/structure/views/view/' . $view->name . '/edit/' . $view->current_display;
// Try to build the Juicebox gallery.
try {
// Initialize the gallery.
$this->juicebox
->init($xml_args, $this->options, $view);
// Build the gallery.
$this
->buildGallery();
// Render the embed code.
$element = array(
'gallery' => $this->juicebox
->buildEmbed($xml_path, TRUE, $context),
);
} catch (Exception $e) {
$message = 'Exception building Juicebox embed code for view: !message in %function (line %line of %file).';
watchdog_exception('juicebox', $e, $message);
}
return $element;
}