public function JuiceboxXmlViewsStyle::getXml in Juicebox HTML5 Responsive Image Galleries 7.2
Get the XML based on loaded data.
Return value
string Returns XML data describing a Juicebox gallery.
Overrides JuiceboxXmlInterface::getXml
File
- plugins/
JuiceboxXmlViewsStyle.inc, line 61 - Juicebox XML loader that's used to load (and build via loaded methods) the XML associated with a Drupal views style formatter plugin.
Class
- JuiceboxXmlViewsStyle
- Class to load and build the XML associated with a Drupal views style formatter plugin.
Code
public function getXml() {
// Execute the view and build the gallery. This is easiest to do by simply
// calling the preview() method (as it handles all needed sub-processes).
$this->view
->preview($this->viewDisplay, $this->viewArgs);
// See if if the galley is actually built. The preview() method above
// typically triggers the Juicebox init and build processes, but under
// certain caching situations these may be skipped (e.g., if the raw view
// html is returned from a cache instead of calling the formatter logic).
$juicebox = $this
->getJuiceboxFromData($this->view);
if (!$juicebox) {
// Build the gallery manually via the formatter's render method.
$this->view->style_plugin
->render();
// If we still don't have a built gallery something is wrong.
$juicebox = $this
->getJuiceboxFromData($this->view);
if (!$juicebox) {
throw new Exception(t('Could not get gallery XML from view because the gallery could not be built.'));
}
}
// Render the XML.
return $juicebox
->renderXml();
}