HowTo? Recent images for recent albums

I found the getalbumstatistic and getimagestatistic functions. I'm new to all this and want to use these to make a nested loop where I get each recent album and for each recent album show the most recent images. How do I feed the name of each recent album from the getalbumstatistic function to the name field of the getimagestatistic function?

PS. I can tell already, I'm going need to start learning some PHP...

Comments

  • acrylian Administrator, Developer
    You are on the right track. Use this:
    `<?php <br />
    $latestalbums = getAlbumStatistic(5, "latest");

    foreach ($latestalbums as $latestalbum) {

    printImageStatistic(5, "latest", $latestalbum['title']);

    }

    ?>`

    I think I will add this nested setup as a extra function to the plugin.
  • I plugged it into my theme and got an error (of course). "Invalid argument supplied for foreach()" and a patha nd line number pointing to the "foreach ($latestalbums as $latestalbum) {" line. Any help on whats wrong here? Looking at the page on php.net about foreach I dont see anything suggesting what caused the error.
  • reading over things, is it possible that $latestalbums was created as a string and not an array? That would cause the error on the foreach loop as the docs say it should with any non-array variable.
  • acrylian Administrator, Developer
    You are right, I am sorry...It does not work with 1.1.7, I forgot that the plugin has been modified to return an "usable" array in the svn (which of course I as a dev work mostly with). You need to download the nightly build to use the code above. (maybe you can just use the plugin from there with 1.1.7 if you fear updating, but I haven't tried that).
  • Well, this is going to be used on my site when the theme is complete, so I need to be using a build I can rely on. Also, the theme will be very useful to others, so I'd like it to be usable by those not using the nightly build.

    Is there a way to create recent image listings from each album in a way that works on the standard build?

    Also, another, somewhat unrelated question. On an image page, the images can be paged through with next and previous links. Is it possible to setup an images page that will include all albums, not just one? In chronological order?
  • Nightly builds are pretty stable, but you never know. You certainly should do some testing before you put one up live. There is a great deal of change between the current nightly builds and the 1.1.7 release.

    The image_album_statistics plugin looks like it has not changed much, though. I believe it will work with the 1.1.7 release. Give it a try.

    It is certainly possible to set up page navigation the way you describe. However, it is not simple. We have no functions that do that kind of paging so you would have to code it yourself.
  • Well, this all comes from my desire to have a good art blog. I want a good navigable gallery, and a way for people too see the most recent images easily.

    In any case. I fixed your code to work on 1.1.7 the way I expected it to the first time. It was a fairly simple and silly thing.

    `<?php<br />
    $latestalbums = array(getAlbumStatistic(3, "latest"));

    foreach ($latestalbums as $latestalbum) {

    printImageStatistic(3, "latest", $latestalbum['title']);

    }

    ?>`

    You can see the results at my site, www.ronquillostudios.com

    its the stopdesign theme, with the latest gallery output replaced by the above code. Pics are all test images to populate a couple albums.

    EDIT: for some reason the loop is only outputing three images, not three from each of the three albums...
  • acrylian Administrator, Developer
    EDIT: for some reason the loop is only outputing three images, not three from each of the three albums...
    That is because your fix fixed the error but not the functionality. The array that is returned does not have the structure that you need. Please try the plugin from the nightly. As sbillard already said it probably will work with 1.1.7 without any problems.
  • Is there any way to get this to grab a size other than thumbnail?
  • acrylian Administrator, Developer
    Not at this time unless you want to hack the plugin. But I have it on my list to add that to the next version.
  • I'm willing to mess with the php, any hints on a starting point?

    [I don't need to have it be an option for the purposes of my hackery: totally fine with simply replacing the thumb grab with a medium-sized image grab.]
  • You need to change the following two lines:
    `
    $albumthumb = $tempalbum->getAlbumThumbImage();
    echo "imagename."&i=".$albumthumb->name."&s=75&cw=75&ch=75\">\n";
    `
    Change to something like:
    `
    $albumthumb = $tempalbum->getAlbumThumbImage();
    $url = $albumthumb ->getCustomImage($size, $width, $height, $cropw, $croph, $cropx, $cropy, true);
    echo "img src=".$url.">\n";
    `
    where you have filled in $size, etc. with the values you want.
  • Thank youuuuu. Since I was printing images (instead of grabbing albums) I did something like:

    `
    foreach ($images as $image) {
    echo "getImageLink() . "\" title=\"" . html_encode($image->getTitle()) . "\">\n";
    $url = $image ->getCustomImage('default', null, null, null, null, null, null, true);
    echo "\getTitle()) . "\" />
    \n";
    `
    Working like a charm.
  • is there any reason using `echo $image->getTags();` within printImageStatistic returns an empty array for each image?
  • Thank you for the code Stephen ! Marvelous !

    (I just noticed, as far as I know, that `echo "img src=".$url.">\n";` is supposed to be `echo "image\n";`)
  • Hey everybody... i was following this post, but i have a question:

    Is there a way to publish recent photos outside of the zenphoto folder/template?
    I have zenphoto on its own folder and have an index php file on my server like homepage, is there a way to display the thumbnails on it?

    Peace
Sign In or Register to comment.