Is it possible to call the first image of the first album directly into index.php? Currently I have to click through the link for an album, and then choose an image in order to see anything. That's a few more steps than I'd like. Ideally when the link to the zenphoto site is clicked the code would serve the first image up. I've already built the links to the other albums and the thumbnails for the current album into image.php so there's a way back. I'd rather not have to hard-code the link to the first image since this is for a client and it's quite possible that link would have to change regularly. Perhaps something like the "set context" call but for the first album of the set?
Comments
I would also like to have this feature. Does anyone know how to get this to work?
`global $_zp_gallery;
$alb = $_zp_gallery->getAlbums(0);
$first = $alb[0];
$firstAlbum = new Album($_zp_gallery, $first);
$img = $firstAlbum->getImages(0);
$first = $img[0];
$firstImage = new Image($firstAlbum, $first);`
What I would like to have is the normal index page that lists albums with thumbnails, but instead of showing the album view when a user clicks on a thumbnail from the index page, I would like it to link to the album's first image. Is there a way I could sidestep the album view page?
Where on the album.php page should I paste the above code?
Here's my album.php page:
`<?php $startTime = array_sum(explode(" ",microtime())); if (!defined('WEBPATH')) die(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php printGalleryTitle(); ?>
/zen.css" type="text/css" />
<?php printRSSHeaderLink('Gallery','Gallery RSS'); ?>
<?php zenJavascript(); ?>
" title="Gallery Index"><?php echo getGalleryTitle();?>
<?php printAlbumTitle(true);?>
<?php while (next_image()): ?>
<?php printImageThumb(getImageTitle()); ?>
<?php endwhile; ?>
`
A quick tour of the code above:
the `gallerytitle` div is where the name and link back to the gallery page is done.
the `images` is where your image thumbnails are generated.
Note: this theme would not support subalbums. If you are really new to all this I suggest you take one of the existing themes--say the example theme (which is called testing in the 1.1.2 release) as a starting point.
It is index.php which shows the first level albums. Second level albums (subalbums) are normally shown by the album.php page. However what you have above does not do them.
I have tried replacing the `images` div with your code on my album page, but I get a fatal error from the `$img = $album->getImages(0);` line.
Where on the album.php should I add your code?
Perhaps it would be easier for the album link on the index.php page to link straight to the first image of the album. Would this be possible?
Fatal error: Call to a member function getImages()
Is this a new function for ZenPhoto 1.1.2, or should I put the code somewhere else?
You do, of course, have to have a valid album object to use the function.
I upgraded to 1.1.2, put your new code on index.php and changed `getAlbumLinkURL()` to `$firstImage->getImageLink();`.
It does work, except now all of the thumbnails on the index page point to the first photo of the first album. I played around a little and noticed that if I change the number from 0 to 1 in the `$first = $alb[0];` line, the thumbnails would then link to the first image of the second album.
Is there a way for each of the albums on index.php to have their own link be first image of their album?
Here's my index.php file:
`<?php if (!defined('WEBPATH')) die(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php printGalleryTitle(); ?>
/zen.css" type="text/css" />
<?php printRSSHeaderLink('Gallery','TedPhoto'); ?>
<?php zenJavascript(); ?>
<?php echo getGalleryTitle(); ?>
<?php while (next_album()): ?>
<?php global $_zp_gallery;<br />
$alb = $_zp_gallery->getAlbums();
$first = $alb[1];
$firstAlbum = new Album($_zp_gallery, $first);
$img = $firstAlbum->getImages(0);
$first = $img[0];
$firstImage = new Image($firstAlbum, $first);
?>
getImageLink();?>"><?php printAlbumThumbImage(getAlbumTitle()); ?>
getImageLink();?>"><?php printAlbumTitle(); ?>
<?php endwhile; ?>
<?php printAdminToolbox(); ?>
`
I tried to change
`"`
to
`"`
But I guess you need to define what album you'r trying to enter.