I posted this at http://drupal.org/node/41259, but it's so far down the list I'm sure it will be missed so am posting it again in a new topic.
When I first asked how to modify the look of the image gallery I couldn't get it to work and ended up directly modifying image_gallery.module instead (I know it's not the drupal way). I since decided I want to use the hook that is described in the above handbook page, but when I do it goes from not looking how I want to not showing at all.
I followed the instructions, inserting the following into template.php:
<?php
/**
* Catch the theme_image_gallery function, redirect through the template api
* and point Drupal to your image_gallery.tpl.php file to determine the layout
* of your image gallery pages.
*/
function phptemplate_image_gallery($galleries, $images) {
// Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
// will be assigned within your template.
/* potential need for other code to extract field info */
return _phptemplate_callback('image_gallery', array('galleries' => $galleries, 'images' => $images));
}
?>Then I created image_gallery.tpl.php, copying the theming section from image_gallery.module as follows:
<?php
/**
* Theme a gallery page
*/
// We'll add height to keep thumbnails lined up.
$size = _image_get_dimensions('thumbnail');
$width = $size['width'];
$height = $size['height'];
$content = '';
if (count($galleries)) {
$content.= '<ul class="galleries">';
foreach ($galleries as $gallery) {
// $content .= '<li style="height : '.$height .'px">';
if ($gallery->count)
$content.= l(image_display($gallery->latest, 'thumbnail'), 'image/tid/'.$gallery->tid, array(), NULL, NULL, FALSE, TRUE);
$content.= "<h3>".l($gallery->name, 'image/tid/'.$gallery->tid) . "</h3>\n";
$content.= '<div class="description">'. check_markup($gallery->description) ."</div>\n";
$content.= '<p class="count">' . format_plural($gallery->count, 'There is 1 image in this gallery', 'There are %count images in this gallery') . "</p>\n";
if ($gallery->latest->changed) {
$content.= '<p class="last">'. t('Last updated: %date', array('%date' => format_date($gallery->latest->changed))) . "</p>\n";
}
$content.= "</li>\n";
}
$content.= "</ul>\n";
}
if (count($images)) {
$height += 75;
$content.= '<ul class="images">';
foreach ($images as $image) {
$content .= '<li';
if ($image->sticky) {
$content .= ' class="sticky"';
}
$content .= ' style="height : '.$height .'px; width : '.$width.'px;"';
$content .= ">\n";
$content .= l(image_display($image, 'thumbnail'), 'node/'.$image->nid, array(), NULL, NULL, FALSE, TRUE);
$content .= '<br />'.l($image->title, 'node/'.$image->nid);
if (theme_get_setting('toggle_node_info_' . $image->type)) {
$content .= '<div class="author">'. t('Posted by: %name', array('%name' => theme('username', $image))) . "</div>\n";
if ($image->created > 0) {
$content .= '<div class="date">'.format_date($image->created)."</div>\n";
}
}
$content .= "</li>\n";
}
$content.= "</ul>\n";
}
if ($pager = theme('pager', NULL, variable_get('image_images_per_page', 6), 0)) {
$content.= $pager;
}
If (count($images) + count($galleries) == 0) {
$content.= '<p class="count">' . format_plural(0, 'There is 1 image in this gallery', 'There are %count images in this gallery') . "</p>\n";
}
return $content;
?>As I said, nothing shows at all so if anyone can help or point me in the right direction it would be appreciated.
Comments
My solution
I'm working in Drupal 5.1, not 4.7, but I think the solution is the same. I scratched my head for a while on this myself.
Your code ends with:
return $content;
That's correct for the module, but what you want to do in image_gallery.tpl.php is this:
print $content;
See if that works for you.
SD
have you figured out a way
to get a description of the gallery above the thumbnails themselves? I like your setup here; is there a way to remove the bullets? thanks
I have yet to get this
I have yet to get this working myself but generally
list-style-type: none;in style.css under whatever class it's using should work.
works at bekandloz | plays at technonaturalist