Hint: on the user guide http://www.zenphoto.org/documentation/index.html click on `[all elements]` link in the upper right. This will give you a list of all the functions so that you can search.
I just implemented this in my theme I'm developing, if you're interested here's my code:
Put this function in your theme-functions file (or make one or just put it on your page..). ` function tims_first_album() { save_context(); global $_zp_albums, $_zp_gallery, $_zp_current_album; $_zp_albums = $_zp_gallery->getAlbums('','',''); $_zp_current_album = new Album($_zp_gallery, $_zp_albums[0]); add_context(ZP_ALBUM); } ` Now you can print your latest album just like you would normally print an album, this is how I do it on my index page: `
Your code will return the albums in the order specified by the gallery sort option, which may or may not be ordered by recency. Also, the first parameter to `getAlbums()` is supposed to be numeric. You are just lucky that an empty string evaluates to zero.
`$_zp_albums = $_zp_gallery->getAlbums(0,'id','DESC');` would be a better choice. This would give you the albums in reverse order of discovery.You can also use 'date' for the second parameter to get them by date.
Good advice, I went ahead and changed the getAlbums() parameter as you suggested. For me showing the top sorted album is exactly what I want (I mostly sort my gallery by date but I often post multiple albums at once). Here's the function once more that will show the latest album as ordered by date: (I tested just to be sure it works)
` function tims_first_album() { save_context(); global $_zp_albums, $_zp_gallery, $_zp_current_album; $_zp_albums = $_zp_gallery->getAlbums(0,'date','DESC'); $_zp_current_album = new Album($_zp_gallery, $_zp_albums[0]); add_context(ZP_ALBUM); } ` Zenphoto is a truly amazing work of art, the more I work with it the more I appreciate how simple and versatile it is.
You also could have used the `printLatestAlbums()` function or the `getAlbumStatistic()` variant the plugin mentioned above provides. But of course that would have been some more work to get the layout the normal album way.
Comments
Hint: on the user guide http://www.zenphoto.org/documentation/index.html click on `[all elements]` link in the upper right. This will give you a list of all the functions so that you can search.
Put this function in your theme-functions file (or make one or just put it on your page..).
`
function tims_first_album() {
save_context();
global $_zp_albums, $_zp_gallery, $_zp_current_album;
$_zp_albums = $_zp_gallery->getAlbums('','','');
$_zp_current_album = new Album($_zp_gallery, $_zp_albums[0]);
add_context(ZP_ALBUM);
}
`
Now you can print your latest album just like you would normally print an album, this is how I do it on my index page:
`
<?php tims_first_album(); ?>
" title="<?php echo getAnnotatedAlbumTitle();?>">
" width="100" height="100" alt="<?php html_encode(getAnnotatedAlbumTitle()); ?>" />
" title="<?php echo getAnnotatedAlbumTitle();?>">
<?php printAlbumDate(); ?><?php printAlbumTitle(); ?>
<?php restore_context(); ?>
`
Right now my development is going on at http://test.t413.com and it will be moved to my main site t413.com pretty soon.
`$_zp_albums = $_zp_gallery->getAlbums(0,'id','DESC');` would be a better choice. This would give you the albums in reverse order of discovery.You can also use 'date' for the second parameter to get them by date.
`
function tims_first_album() {
save_context();
global $_zp_albums, $_zp_gallery, $_zp_current_album;
$_zp_albums = $_zp_gallery->getAlbums(0,'date','DESC');
$_zp_current_album = new Album($_zp_gallery, $_zp_albums[0]);
add_context(ZP_ALBUM);
}
`
Zenphoto is a truly amazing work of art, the more I work with it the more I appreciate how simple and versatile it is.