Theming the drupal gallery modul
template.php:
modify the image gallery templates
#000000">#0000BB"><?php
#FF8000">/*image gallery*/
#007700">function #0000BB">phptemplate_image_gallery#007700">(#0000BB">$galleries#007700">, #0000BB">$images#007700">) {
#0000BB">drupal_add_css#007700">(#0000BB">drupal_get_path#007700">(#DD0000">'module'#007700">, #DD0000">'image_gallery'#007700">) .#DD0000">'/image_gallery.css'#007700">);
#0000BB">drupal_add_js#007700">(#0000BB">$data #007700">= #DD0000">'misc/jquery.js'#007700">, #0000BB">$type#007700">=#DD0000">'theme'#007700">, #0000BB">$scope#007700">=#DD0000">'header'#007700">, #0000BB">$defer#007700">=#0000BB">FALSE#007700">, #0000BB">$cache#007700">=#0000BB">TRUE#007700">);
#0000BB">drupal_add_js#007700">(#0000BB">$data #007700">= #0000BB">path_to_theme#007700">().#DD0000">'/jquery_gallery.js'#007700">, #0000BB">$type#007700">=#DD0000">'theme'#007700">, #0000BB">$scope#007700">=#DD0000">'header'#007700">, #0000BB">$defer#007700">=#0000BB">FALSE#007700">, #0000BB">$cache#007700">=#0000BB">TRUE#007700">);
#FF8000">// We'll add height to keep thumbnails lined up.
#0000BB">$size #007700">= #0000BB">_image_get_dimensions#007700">(#DD0000">'thumbnail'#007700">);
#0000BB">$width #007700">= #0000BB">$size#007700">[#DD0000">'width'#007700">];
#0000BB">$height #007700">= #0000BB">$size#007700">[#DD0000">'height'#007700">];
#0000BB">$content #007700">= #DD0000">''#007700">;
if (#0000BB">count#007700">(#0000BB">$galleries#007700">)) {
#0000BB">$content#007700">.= #DD0000">'<ul class="galleries">'#007700">;
foreach (#0000BB">$galleries #007700">as #0000BB">$gallery#007700">) {
#FF8000">// $content .= '<li style="height : '.$height .'px">';
#0000BB">$content #007700">.= #DD0000">'<li>'#007700">;
if (#0000BB">$gallery#007700">->#0000BB">count#007700">)
#0000BB">$content#007700">.= #DD0000">"<h3>"#007700">.#0000BB">l#007700">(#0000BB">$gallery#007700">->#0000BB">name#007700">, #DD0000">'image/tid/'#007700">.#0000BB">$gallery#007700">->#0000BB">tid#007700">) . #DD0000">"</h3>\n"#007700">;
#0000BB">$content#007700">.= #0000BB">l#007700">(#0000BB">image_display#007700">(#0000BB">$gallery#007700">->#0000BB">latest#007700">, #DD0000">'thumpnail_gallery'#007700">), #DD0000">'image/tid/'#007700">.#0000BB">$gallery#007700">->#0000BB">tid#007700">, array(), #0000BB">NULL#007700">, #0000BB">NULL#007700">, #0000BB">FALSE#007700">, #0000BB">TRUE#007700">);
#0000BB">$content#007700">.= #DD0000">'<div class="description">'#007700">. #0000BB">check_markup#007700">(#0000BB">$gallery#007700">->#0000BB">description#007700">) .#DD0000">"</div>\n"#007700">;
#FF8000">//$content.= '<p class="count">' . format_plural($gallery->count, '1', ' @count images') . "</p>\n";
// if ($gallery->latest->changed) {
// $content.= '<p class="last">'. t('Last updated: %date', array('%date' => format_date($gallery->latest->changed))) . "</p>\n";
// }
#0000BB">$content#007700">.= #DD0000">"</li>\n"#007700">;
}
#0000BB">$content#007700">.= #DD0000">"</ul>\n"#007700">;
}
if (#0000BB">count#007700">(#0000BB">$images#007700">)) {
#0000BB">$content#007700">.= #DD0000">'<div id="gallery_thumpnail" class="blockElm">'#007700">;
#0000BB">$content#007700">.= #DD0000">'<ul class="images">'#007700">;
foreach (#0000BB">$images #007700">as #0000BB">$image#007700">) {
#0000BB">$content #007700">.= #DD0000">'<li'#007700">;
if (#0000BB">$image#007700">->#0000BB">sticky#007700">) {
#0000BB">$content #007700">.= #DD0000">' class="sticky"'#007700">;
}
#0000BB">$content #007700">.= #DD0000">">\n"#007700">;
#0000BB">$content #007700">.= #0000BB">l#007700">(#0000BB">image_display#007700">(#0000BB">$image#007700">, #DD0000">'thumbnail'#007700">), #DD0000">'files/'#007700">.#0000BB">$image#007700">->#0000BB">images#007700">[#0000BB">preview#007700">], array(#DD0000">"title"#007700">=>#DD0000">"$image->title"#007700">), #0000BB">NULL#007700">, #0000BB">NULL#007700">, #0000BB">FALSE#007700">, #0000BB">TRUE#007700">);
#0000BB">$content #007700">.= #DD0000">"</li>\n"#007700">;
}
#0000BB">$content#007700">.= #DD0000">"</ul>\n</div>\n\n"#007700">;
#0000BB">$content#007700">.= #DD0000">'<div id="gallery_image_placeholder" class="blockElm">'#007700">;
#FF8000">// $content .= '<h3 id="description">'.$image->title."</h3>";
#0000BB">$content#007700">.= #0000BB">image_display#007700">(#0000BB">$image#007700">, #DD0000">'gallery'#007700">, array(#DD0000">"id"#007700">=>#DD0000">"gallery_image"#007700">));
#0000BB">$content#007700">.= #DD0000">'</div>'#007700">;
}
if (#0000BB">$pager #007700">= #0000BB">theme#007700">(#DD0000">'pager'#007700">, #0000BB">NULL#007700">, #0000BB">variable_get#007700">(#DD0000">'image_images_per_page'#007700">, #0000BB">6#007700">), #0000BB">0#007700">)) {
#0000BB">$content#007700">.= #0000BB">$pager#007700">;
}
If (#0000BB">count#007700">(#0000BB">$images#007700">) + #0000BB">count#007700">(#0000BB">$galleries#007700">) == #0000BB">0#007700">) {
#0000BB">$content#007700">.= #DD0000">'<p class="count">' #007700">. #0000BB">format_plural#007700">(#0000BB">0#007700">, #DD0000">'There is 1 image in this gallery'#007700">, #DD0000">'There are @count images in this gallery'#007700">) . #DD0000">"</p>\n"#007700">;
}
return #0000BB">$content#007700">;
}
#0000BB">?>jquery_gallery.js:
the code is based on some stuff i found looking around in the jquery mailling list (http://www.nabble.com/DOM-Gallery-tf2035979.html#a5605423)
/*simple img gallery jQuery style*/
$(function(){
$('div#gallery_thumpnail a').click(function() {
$('#gallery_image').hide().attr('src', this.getAttribute ('href'));
$('#gallery_image').attr('height', this.getAttribute ('href'))
$('#gallery_image').attr('width', this.getAttribute ('href'))
$('#description').html(this.getAttribute("title")||"");
return false; // prevent following links
});
$('#gallery_image').load(function(){$(this).fadeIn('slow');});
});| Attachment | Size |
|---|---|
| jquery_gallery.js.txt | 708 bytes |
| template_image_gallery.txt | 2.49 KB |

