ZenphotoCMS Forum
list latest album - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: Themes (https://forum.zenphoto.org/forum-5.html)
+--- Thread: list latest album (/thread-5469.html)



list latest album - Ruriko - 11-07-2009

How can I list the latest 10 albums in a list format and linked?




list latest album - sbillard - 11-07-2009

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.




list latest album - timo - 15-07-2009

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:
`

        ">
    [img][/img]" />


        ">

browse the library

`
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.




list latest album - sbillard - 15-07-2009

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.




list latest album - timo - 15-07-2009

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.




list latest album - acrylian - 15-07-2009

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.




list latest album - inertiawebdesign - 14-09-2009

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.