Search Page Image Album

I created a search page that searches for images throughout Zenphoto...everything works great except for one thing:

In my while I am trying to display which album an image is from...example: searching for "Blue" might return a picture of a crayon, underneath the picture it would read "Album: School Supplies".

My while is next_image, which is why my current code isn't working: echo getAlbumTitle()...I'm thinking because it needs to be in next_album while instead, but you cannot put a while inside a while (or at least I don't know how to)...so I'm stuck.

Any ideas?
Thanks,
Josh

Comments

  • acrylian Administrator
    You have to use the object model, specifially the album class. Please see the tutorial.
  • acrylian,

    I looked through the tutorial, but I'm not sure how to use the global variables...I tried <?php echo $_zp_current_album->getTitle(); ?> which states that it returns the album title, but it didn't work :(

    Thanks,
    Josh
  • acrylian Administrator
    Sorry, you have to first get the album object of the current image in the loop via the image class and then you have to use the album class. Within search the current album is only set within the next_album loop.
  • acrylian,

    Sorry man, just not sure what to do here...I tried:

    <?php echo $albumobject = new Album($_zp_current_image->getTitle()); ?>
    <?php echo $albumobject = new Image($_zp_current_album->getTitle()); ?>
    <?php echo $_zp_current_image->$_zp_current_album->getTitle()); ?>

    I wish I knew more about objects :(

    Thanks,
    Josh
  • Guess you will have to learn. For starters look at the constructors for the album and image objects. They require parameters quite different from what you have placed in your code above.

    `$albumobject = $_zp_current_image->album;` will get you the album object for the current image. If you are going to instantiate an image you need to use the `newImage()` function unless you know for sure what "kind" of image it is.

    Sorry, but if you are going to step into the world of customizing your Zenphoto gallery there is no shortcut to learning about its structure and object model.
  • sbillard,

    Ok...so, I went and looked at the `newImage()` function and ended up with: `<?php $albumobject = $_zp_current_image->album; echo $imageobject = $albumobject->getTitle(); ?>`. Now, the album name is showing-up correctly...yay!!!

    Thank you acrylian and sbillard!!!

    Josh
  • acrylian Administrator
    Yep, that's it. `echo $imageobject = $albumobject->getTitle();` is too much, just `echo $albumobject->getTitle();` is enough.
  • acrylian,

    Cool, made the change...works like a champ!!

    Thanks again!!
    Josh
Sign In or Register to comment.