image loop

I am currently trying to create an image loop for a particular album using the <?php while (next_image()): ?> loop with no success.

I am making this on the index page of the theme I am creating. I believe that the function makeAlbumCurrent is setting to define the album for the images.

Comments

  • acrylian Administrator, Developer
    Yes, make makeAlbumCurrent() is the right function to use. But you need to create an object of the album you wish to use and pass that to that function. See the documentation of the function and also read the object model tutorial. All on the user guide.
  • Thank you acrylian. But i am getting the error "Bad gallery in instantiation of album slideshow"

    <?php $albumobject = new Album($galleryobject,"slideshow"); ?>
  • The code above I took from the Object Model Guide, but I found in the forums:
    <?php $albumobj = new Album($_zp_gallery, "slideshow"); ?>

    Seams to work!
    Which is the correct code?

    But i cannot pass the <?php while (next_image()): ?> Loop with this??

    Here is my code:
    <?php $albumobj = new Album($_zp_gallery, "slideshow"); ?>
    <?php makeAlbumCurrent("slideshow"); ?>

    <?php while (next_image()): ?>
    <div class="image">
    </div>
    <?php endwhile; ?>
  • acrylian Administrator, Developer
    $_zp_gallery is a standard global object variable that contains the gallery object on themes so you don't need to create it. "$galleryobject" did not work because it does not contain the gallery object. You would need to create it first.

    makeAlbumCurrent() requires the album OBJECT, not the name. Pass the object you just setup with $albumobject.
  • Thank you acrylian, looks like i need to brush up on my object skills in php!

    For the attention of other forum uses (as I know i was searching around for this code for a while) this is how i selected a particular album:
    <?php $galleryobject = new Gallery(); ?>
    <?php $albumobject = new Album($galleryobject,"<folder name of the album>"); ?>
    <?php makeAlbumCurrent($albumobject); ?>

    I could then run the while loop to list the images in a particular album which enable me to use nivo slider from a zenphoto album.

    <?php while (next_image()): ?>
    <img src="/albums<?php echo html_encode(getImageLinkURL());?>" alt="" />
    <?php endwhile; ?>
  • acrylian Administrator, Developer
    You don't need to setup the gallery object, it is already on all theme pages and containted in `$_zp_gallery`. On our user guide there is also an (uncomplete) list of common global variables.
  • I did suspect that, but it works better with it in. If I don't have that line in I get this error message:

    Notice: Bad gallery in instantiation of album slideshow. in C:\Users\Tom\My Dreamweaver\Project Folder\Zen Photo Trial\www\zp-core\class-album.php on line 48
  • acrylian Administrator, Developer
    Of course you would have to replace `$galleryobject` with `$_zp_gallery`....
Sign In or Register to comment.