Dynamic album to show most recent photos/videos

I have looked but can't find a way to create a dynamic album to show the n latest items, or all items from the last 24 hours, week or year for example. How do I do that?

Comments

  • acrylian Administrator, Developer

    latest items

    That would be sortorder by some date or ID (= upload order)

    last 24 hours, week or year

    This is not possible predefined.

  • vincent3569 Member, Translator

    hi
    rather using dynamic album to show latest item, you may use the function printImageStatistic() to do that.
    see https://docs.zenphoto.org/1.5.3/function-printImageStatistic.html

  • Hi,
    Is there a way to limit number of items in a dynamic album sorted by ID using specific code block of the dynamic album? Using this mechanism, is it also possible to define a date criteria (current month for instance)?
    Could you give some code examples on how to do that?
    Thanks!

  • acrylian Administrator, Developer
    edited October 2020

    A dynamic album is just a search so you can define search condition on basically any field/column in the database. You cannot limit the results per se because its a search results.

    If it is just the output on the theme, you can use the album class directly. Just loop through them and filter as needed by date and number. See the album class(es) for available methods to use.

  • Thanks @acrylian. Is the code block section of the dynamic album the correct place to put the code?

  • acrylian Administrator, Developer
    edited October 2020

    I can't tell where to put the code as I don't exactly know where you want to do this ;-) I for example bascially avoid using code block as you easily forget where you put what and do everything within theme files directly.

    If you displaying the album via the normal album.php page as any other album, you need to modify the theme's album.php and it's next_album loop for this specific album. Or create a custom album.php layout to for example use the multiple layouts plugin. Depend

  • Thanks. I modify the album.php. I have added a test on an empty static album (nouveautes) and I would like to fill it with getImageStatistic to publish the result images array into the album. Do you know how to do that?

     if ($_zp_current_album->getFileName()=='nouveautes') {
                            getImageStatistic(12,"latest","", true);
     }
    
  • acrylian Administrator, Developer

    You need to look at the documentation. Base rule of all functions and methodes is basically everywhere:

    • getfunctions just gets data
    • print functions do output

    Get function exists so you can create your own custom output if needed.

    You can also use a dynamic album and the album object to limit the output and the pages using the object. That is easier as you don't have to adjust CSS for this and just re-use the album styles.

    Generally if you modify album.php the cleanest way is to use the multiplelayouts plugin and create a specific album layout page for it and assign that to the album in question.

    Also if you don't use the "album" functionality itself it might be worth a though to use either a Zenpage page or a static custom page for this. As naturally just chaning the code does not touch other album specific things like pagination etc.

  • Thanks @acrylian.

    At first place I was trying to use dynamic album object within my single theme but I did not succeed to limit the output easily (performance was very slow, it was loading all photos before starting the image loop as search criteria is all the photos but the latest).

    I will persevere on this path using doc objects nevertheless which sounds the easiest...

    Question: Does ZP support child theme (to use multiplelayout and change album.php only)?

  • acrylian Administrator, Developer

    At first place I was trying to use dynamic album object within my single theme but I did not succeed to limit the output easily (performance was very slow, it was loading all photos before starting the image loop as search criteria is all the photos but the latest).

    You could try for example set the object properties to limit the items per page to avoid loading all. But the problem is a dynamic album works with dynamic search results so there is is not a static set of data like on physical albums.

    Does ZP support child theme

    No. But you can just add a new album-*.php page to your exsitign theme and use that with the plugin. It does not affect the rest of the theme.

  • Thanks @acrylian. I worked it out.

Sign In or Register to comment.