Member
Member
Ruriko   2009-07-11, 11:43
#1
How can I list the latest 10 albums in a list format and linked?
Member
Member
sbillard   2009-07-11, 16:27
#2
http://www.zenphoto.org/documentation/plugins/_plugins---image_album_statistics.php.html#functionprintLatestImages

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.
Member
Member
timo   2009-07-15, 01:41
#3
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:
`

<?php tims_first_album(); ?>
<div class="albumthumb">
">
[img]<?php echo htmlspecialchars(getAlbumThumb());?>[/img]" />


">
<?php printAlbumTitle(); ?> <?php printAlbumDate(); ?>

<?php printAlbumDesc(); ?>


> browse the library
<?php restore_context(); ?>
</div>
`
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.
Member
Member
sbillard   2009-07-15, 02:27
#4
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.
Member
Member
timo   2009-07-15, 03:50
#5
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.
Administrator
Administrator
acrylian   2009-07-15, 07:31
#6
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.
Member
Member
inertiawebdesign   2009-09-14, 18:23
#7
Just wanted to drop a quick line to thank you Tim. I've been struggling to do almost exactly this for a while. Great job.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.