How to: no album.php, but a direct link to image.php ?

Hi,

I'm reviewing sources of different themes and the docs, but still, I don't completely understand how to bypass the album.php page in theme I'm making.

I'd like that a link to the-Gallery opened the first image in the-Gallery (with next/previous buttons in the bottom), with no index of images at all on the page. I want link to target directly the image.php page. How to do it? How to get a direct link to first image from the-Gallery to put it into the menu? What is the php function for that?

Thanks in advance for help. Greetz!

Comments

  • acrylian Administrator, Developer
    Do you want to skip the albums list on index.php, too? Or do you want to link from the albums listed there to the first image?
  • I want just a link to the first image in album.

    I'll describe it. I want:
    * index.php with a menu listing all albums
    * a link from index.php menu targets directly to the first image in the-Gallery (album listed in menu)
    * by clicking on the link you go directly to image.php (bypassing album.php) and view images (one image per page) only by clicking "previous" and "next" buttons (with no index, or with some but for now it doesn't matter)

    Now it should be clear : )

    I want it to be totally simple, that's why I have chosen ZenPhoto : )

    Greetz.
  • acrylian Administrator, Developer
    Then localte on index.php the `next_album()` loop and and change this part
    ` " title="View album: <?php echo getAlbumTitle();?>"><?php printAlbumThumbImage(getAlbumTitle()); ?>`

    to something like this

    `<;?php $firstimage = $_zp_current_album->getImages(); ?>

    " title="View album: <?php echo getAlbumTitle();?>"><?php printAlbumThumbImage(getAlbumTitle()); ?>`
  • Thanks, that's probably it : )

    Greetz.
  • Better would be
    `<?php $images = $_zp_current_album->getImages();

    $image = new Image($_zp_current_album, array_shift($images)); ?>

    getImageLink(); ?> title="View album: <?php echo getAlbumTitle();?>"><?php printAlbumThumbImage(getAlbumTitle()); ?>`

    But note, this will not work for dynamic albums. The code gets a little more complicated if you want to support them.
  • Thanx! Wow, that's a great support : )
  • Greetings,

    I DO want to skip the albums list on index.php; one of my installations of Zen Photo is for a one-album gallery called Portfolio:

    http://www.lindsayhutchens.com/portfolio

    I want to bypass both index.php and album.php, while showing all the thumbnails and one larger image on image.php.

    The thumbnail part I think I can figure out, however I am wondering about a redirect to get the user straight onto image.php (or album.php if I decide to combine the functions there). I want to make a dynamic link to the first image in my main navigation, without using the imageTitle (currently in the URL).... any suggestions?

    Thanks in advance, you guys rock :)

    -Marcy
  • Simplest is to replace the index.php in your theme with:
    `
    <?php
    header("location: /index.php/«album»/«image»");
    ?>
    `
    Otherwise you will have to replace indes.php with the code for your image page. But if you do this you will have to initialize the state so that zenphoto thinks it is processing an image.
  • Sweet! Thanks for the swift reply. I figured as much, though I am still unclear on what to use in place of <<image>>, is there an integer I can use rather than hard coding the image title? Currently to get to the first image, I could redirect to:

    http://www.lindsayhutchens.com/portfolio/index.php?album=portfolio&image=IrelandPortrait_web.jpg

    However, I would like to replace 'image=IrelandPortrait_web.jpg' with 'image=1' or something similar in case my client changes the first image.

    I actually got the thumbnails integrated since my post a few minutes ago, it was so easy! The only thing I still need to figure out is how to highlight the current thumbnail's border color. Is there a function, property, or hack to get the current thumbnail?

    Thanks a gajillion, you're the best.
  • You have to put the name of the image you want loaded. The concept of "fisrt image" is a tricky one because that will depend on the sort order chosen. You can create an album object for the album and use `$images = $albumobject->getImages();` to get an array of the image names in the album. Then you could use `$images[0]` for the image name.
  • Hi sbillard/marc_sss. Sorry for jumping in on your thread - I hope I haven't broken any blogging etiquette, I'm new to this. sbillard has been helping me with another problem but having read these comments I would like to bin my original idea and copy your idea of jumping straight to the image.php page. However I can't get it to work - I have replaced the code on theme/index.php with

    <?php
    header("location: /index.php/«album»/«image»");
    ?>

    However I do not understand the instruction: you will have to initialize the state so that zenphoto thinks it is processing an image. I also don't understand how to implement the final instructions - "create an album object for the album and use $images = $albumobject->getImages(); to get an array of the image names in the album. Then you could use $images[0] for the image name."

    My site is hedshot.co.uk.

    Any chance you could break it down into really simple steps for me? I realise I am taking up a lot of your time - I would be happy to pay you for your services as I really, really appreciate your help.
  • the items within «» are meta items. You need to substitute for them the actual album folder name and image name you want to be displayed.

    This is getting into PHP programming, so if you are not comfortable with that, go no further.

    `
    <?php
    $onealbum = new Album($_zp_gallery, 'my_one_album');
    $images = $onealbum->getImages();
    $image = $images[0];
    header("location: /index.php/my_one_album/$image");
    ?>
    `
  • Thanks for the tips, sbillard. That looks very similar to Actionscript, actually... I love PHP!

    Jeff, regarding your question about skipping album.php, in case you still need help here are the links that helped me out! I actually have two different installs on the same site, one that uses the thumbnail on index.php as a link straight to image.php; the other redirects straight to image.php but has the thumbnails on the page. If you already know how to do all this, please disregard! :)

    http://www.zenphoto.org/support/topic.php?id=3156
    http://www.zenphoto.org/support/topic.php?id=752&replies=10
Sign In or Register to comment.