image next and previous issue when combining 'album.php' and 'image.php'

Hi there,

I have created a custom theme based on the zenpage default theme and have combined album.php and image.php to have the images load in the same page as the thumbnails (album.php file). I am now trying to get next and previous buttons so that viewers can click through the images easily but am having trouble getting it to work. I pulled this code from image.php:

<div class="imgnav">
<?php if (hasPrevImage()) { ?>
<div class="imgprevious">" title="<?php echo gettext("Previous Image"); ?>">« <?php echo gettext("prev"); ?></div>
<?php } if (hasNextImage()) { ?>
<div class="imgnext">" title="<?php echo gettext("Next Image"); ?>"><?php echo gettext("next"); ?> »</div>
<?php } ?>

and plugged it to the album.php page, but it is bringing up nothing. Here is a link to one of the albums on the site in question:

http://heatherwb.com/portfolios/commercial-campaign-editorial/

if anyone could offer advice, I would greatly appreciate it! Thanks. :D

Comments

  • acrylian Administrator, Developer
    So you added the sized image to album.php? That will not work this way. Adding the thumbnails (next_image loop) to image.php is far more easier. But of course you will have to change the link to skip the normal thumbnail view. Please try a forum search, we had that several times.
  • thanks for your advice, acrylian. I actually added the unsized image to album.php this way:

    " title="<?php echo getBareImageTitle();?>"><?php printImageThumb(getBareImageTitle()); ?>

    and that part works just fine, as can be seen here:

    http://heatherwb.com/portfolios/commercial-campaign-editorial/

    I just can't get the next and previous php to work correctly. The if/then in the next and previous php isn't bringing anything up. I have seen the forum posts about adding thumbs to image.php, but since I already did the whole site this way, I guess I was hoping that there were other options that didn't involve redoing what I have already done. If not, I'll just have to go that route, but I'll still keep my fingers crossed for a couple of days. So if anyone out there has a suggestion...

    Thanks!
  • acrylian Administrator, Developer
    Well, it is not a big change I think. All you need to do is to change the link that normal goes to the thumbnail view. Use this within the next_album loop on album.php (or index.php depending if you have subalbums or not):

    `
    <?php $firstimage = $_zp_current_album->getImages(); ?>
    ">...
    `
    That's all. This links to image.php and shows the first image.
  • please pardon me - I am a complete php novice. I know just enough to be a danger to myself. :) Thinking that I knew what you meant, I tried this:

    "><?php while (next_album()): ?>

    which did not seem to help. I am using this javascript to bring up the large images:

    <script type="text/javascript" language="javascript">
    function showPic (whichpic) {
    if (document.getElementById) {
    document.getElementById('placeholder').src = whichpic.href;
    if (whichpic.title) {
    document.getElementById('desc').childNodes[0].nodeValue = whichpic.title;
    } else {
    document.getElementById('desc').childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
    }
    return false;
    } else {
    return true;
    }
    }
    </script>

    and this is the relevant code within the page:

    <div id="albums">
    <?php while (next_album()): ?>
    <div class="album">

    <div class="thumb">
    " title="<?php echo gettext('View album:'); ?> <?php getBareAlbumTitle();?>"><?php printCustomAlbumThumbImage(getBareAlbumTitle(), NULL, 95, 95, 95, 95); ?>
    </div>

    <div class="albumdesc">
    <h3>" title="<?php echo gettext('View album:'); ?> <?php echo getBareAlbumTitle();?>"><?php printAlbumTitle(); ?></h3>
    <small><?php printAlbumDate(""); ?></small>
    <p><?php echo truncate_string(getAlbumDesc(), 45); ?></p>
    </div>
    <p style="clear: both; "></p>
    </div>
    <?php endwhile; ?>
    </div>
    <div id="images">
    <?php while (next_image(false, $firstPageImages)): ?>
    <div class="image">
    <div class="imagethumb">" title="<?php echo getBareImageTitle();?>"><?php printImageThumb(getBareImageTitle()); ?></div>
    </div>
    <?php endwhile; ?>

    </div>

    <div id="bigImage">
    <div class="imgnav">

    <?php if (hasPrevImage()) { ?>
    <div class="imgprevious">" title="<?php echo gettext("Previous Image"); ?>">« <?php echo gettext("prev"); ?></div>
    <?php } if (hasNextImage()) { ?>
    <div class="imgnext">" title="<?php echo gettext("Next Image"); ?>"><?php echo gettext("next"); ?> »</div>

    <?php } ?>
    </div>
    <img id="placeholder" src="../../images/blank.gif" alt="" />
    <p id="desc">Choose an image to begin</p>

    </div>

    I hate to be a pest, but the person I made the site for has suddenly decided that having this functionality is the most important thing on the site. Things I wish I had known to start with... Thanks so much for your help!
  • acrylian Administrator, Developer
    Your site uses javascript to load the image within the page. This is of course not the standard way Zenphoto works which loads actually a new page. If you can live with that you have to do it my way (using image.php and skipping album.php).

    It is possible to do that your way but you will have to write your own php/js function stuff to get the next/prev buttons working.
  • good enough - thanks so much for your help and time.
Sign In or Register to comment.