list latest album

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

Comments

  • 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.
  • timo Member
    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:
    `

    `
    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.
  • 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.
  • timo Member
    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.
  • acrylian Administrator, Developer
    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.
  • 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.
Sign In or Register to comment.