morganhowland.com was a portfolio site for Moragn Howland's photography. Morgan is a professional photographer who was looking for a very simple site layout that would allow him to easily update his photo galleries on a website and provide a slick way for users to browse his work. He didn't want a whole lot of bells and whistles.
The site was built on top Drupal 5.x and leveraged the image, cck number, flash_gallery, and some custom themeing work so that the order or the images in the galleries can be changed.
The theme used is a slightly modified version of cleanstate, with the logo done by David Clark.
This ability to change the order that images are displayed was a specific request from Morgan, and a feature that was not bundled with flash_gallery. Providing this feature was achieved by adding a number cck field to the image node, then overriding the theme_image_gallery() function of flash_gallery.
The code below shows how this ordering was implemented
function cleanstate_image_gallery($galleries, $images) { drupal_add_css(drupal_get_path('module', 'image_gallery') .'/image_gallery.css'); $size = image_get_sizes(IMAGE_THUMBNAIL); $content = \"\"; if (count($galleries)) { $content .= "
- ";
foreach ($galleries as $gallery) {
$content .= "
- ";
if ($gallery->count) {
$content .= l(image_display($gallery->latest, IMAGE_THUMBNAIL), 'image/tid/'. $gallery->tid, array(), NULL, NULL, FALSE, TRUE);
}
$content .= "
". l($gallery->name, 'image/tid/'. $gallery->tid) ."
\n"; $content .= "". check_markup($gallery->description) ."\n"; $content .= ''. format_plural($gallery->count, 'There is 1 image in this gallery', 'There are @count images in this gallery') ."
\n"; if ($gallery->latest->changed) { $content .= ''. t('Last updated: %date', array('%date' => format_date($gallery->latest->changed))) ."
\n"; } $content .= " \n";
}
$content .= "
- ';
foreach ($images as $image) {
$content .= theme('image_gallery_img', $image, $size);
}
$content .= "
". format_plural(0, "There is 1 image in this gallery", "There are @count images in this gallery") ."
\n"; } return $content; } function compareImagesByFieldOrder ($x, $y) { if (isset($x->field_order[0][value]) && !isset($y->field_order[0][value])) { return -1; } else if (isset($y->field_order[0][value]) && !isset($x->field_order[0][value])) { return 1; } else if (!isset($y->field_order[0][value]) && !isset($x->field_order[0][value])) { return 0; } if ($x->field_order[0][value] == $y->field_order[0][value]) { return 0; } else if ($x->field_order[0][value] > $y->field_order[0][value]) { return 1; } else { return -1;} }