Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4levels/458511 to your computer and use it in GitHub Desktop.
Save 4levels/458511 to your computer and use it in GitHub Desktop.
Render a gallery or grid from a records DmGallery behaviour
<?php // Vars: $object
use_stylesheet('/dmCorePlugin/lib/colorbox/theme3/colorbox.css');
use_javascript('/dmWidgetGalleryPlugin/js/cycle/jquery.cycle.lite-1.0.min.js') // for a Gallery
use_javascript('/dmCorePlugin/lib/colorbox/jquery.colorbox.min.js'); // for a Grid
?>
<?php if ($object->getNbMedias()) { ?>
<div class="gallery">
<h3>Object pictures</h3>
<ol class="pictures">
<?php foreach($object->getDmGallery() as $media) { ?>
<li><?php echo _link($media)->set('.colorBox rel=team')->text(
_media($media)->size(48, 48)
) ?></li>
<?php } ?>
</ol>
</div>
<?php } ?>
// for a Gallery
var $gallery = $('ol.gallery');
// only if elements in gallery
if($gallery.find('>li').length) {
// launch jQuery cycle
$gallery.cycle({
timeout: 5000,
height: $gallery.find('img:first').attr('height')
});
}
// for a Grid
var $grid = $('ol.gallery');
// only if elements in gallery
if(!$grid.find('>li').length) {
$grid.find('>li a').colorbox();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment