getAlbumLinkURL() links to page 2 if there's a sub album

Hi,

I'm in the process of cobbling together quite a custom Zenphoto theme for my website. The way it functions isn't quite like your traditional gallery in that there's no need or place for navigation crumbs.

Because of this, when viewing an image, a link back up to the containing album is required. Along comes getAlbumLinkURL().

`
"
title="<?php echo getAlbumTitle(); ?>"><?php echo getAlbumTitle(); ?>

`
This was working just as you'd expect until I added in a sub album and started testing and designing for those.

The problem I'm having is that when I have an album with both images and sub albums in it, for some reason the images always start on page 2.

On the album page I'm using the following, so it gets round the issue by specifying that 12 image thumbnails are allowed to share the first page with sub albums:

`
<?php while (next_image(false, 12)): ?>
`
The problem is that getAlbumLinkURL() still links to the 2nd page of the gallery for images that are seen as being on the first. I realise that getAlbumLinkURL() on image.php is not going to know about the fact I've specified I want image thumbs on the first page, so what I want to know is why does including sub albums suddenly make the rest of the images start on page 2? I'm guessing there's something I'm missing here but with my very limited PHP experience I can't work out what.

My current work around is just to omit the getAlbumLinkURL() and just link to "." as it's better ending up on the first page at least. Of course, it would be nice to restore the functionality where clicking the link brings you to the album page the image is on.

Sorry for the long post but I felt if I explain everything in detail it'll avoid me having to clarify later on.

Comments

  • acrylian Administrator, Developer
    I am not sure I really understand. Normally the getAlbumLinkURL() links to the page you came from.

    But your real problem lies in the sharing of image thumbs and thumbs of sub albums. We have a function that "equals" the look if both appear together. Please search the documentation for "normalizColumns".
  • Yeah, and in this case I'm coming from page 1 and it's linking to page 2. My "Thumbnails per page" option is also set to 12, and everything works fine until I add a sub album.

    Example: I go to page 1 of an album, eg http://domain.tld/new-album-1. I click on an image thumbnail. On the image.php page my getAlbumLinkURL() links to http://domain.tld/new-album-1/page/2 instead, even though the image is not on page 2.

    If I remove the 12 in next_image(false, 12) in the album.php, page 1 only has the sub albums on it, the images then start on page 2. This then matches with what getAlbumLinkURL() is doing.

    So, the ,12 seems to make a "pretend" page 1 for the images. The gallery system still thinks the images start on page 2. I need to correct whatever the underlying reason is for the images starting on page 2.

    Unfortunately due to the layout, normalizeColumns() is not any use to me, but thanks for the suggestion!
  • acrylian Administrator, Developer
    You probably should read the documentation more carefully. You will find:
    `
    bool $all: set to true disable pagination
    int $firstPageCount: the number of images which can go on the page that transitions between albums and images
    `
    So you actually want to use `next_image(true)` to show all images on one page and the 2nd parameter is not even needed at all.

    Since you also have albums, you of course have to set the same for the `next_album()` loop for the albums as well.

    Not knowing your theme at all I referred to `normalizeColumns()` as that often leads to pagination confusion if not used correctly.
  • Thanks for the reply acrylian. The thing is, I do actually want pagination!

    Here's the album view, page 1:
    http://parkside.rguk.eu/s/untitled1.jpg

    And here's page 2:
    http://parkside.rguk.eu/s/untitled3.jpg

    Here's the image view:
    http://parkside.rguk.eu/s/untitled2.jpg

    The red circle shows my link back to the album.

    The above is how I'm wanting it to display. The problem is that the link which I've circled in the image view goes to page 2. This only happens if I have sub albums.

    I hope that this is clearer!

    Cheers
  • acrylian Administrator, Developer
    I guess then it might again come down to the "normalizeColumns()" function usage again. You have to have that calculate the 2nd parameter (the firstpageimages) otherwise the sytems is confused.
  • Ok, I'll have a play about with it, thanks.
  • Turned out all I needed to do to fix it (and another issue where I was ending up on "page 3 of 2" so to speak) was set on each page:

    `
    <?php
    $firstPageImages = getOption('images_per_page');
    $_zp_conf_vars['images_first_page'] = getOption('images_per_page');
    ?>
    `
    Oh well, seems a little obvious to me now, but it wasn't before and examining normalizeColumns helped.

    Thanks for your input!
  • Ok, the above had issues... Here's my final fix:

    `
    <?php
    if (getNumImages() > getOption('images_per_page')) {
    $_zp_conf_vars['images_first_page'] = getOption('images_per_page');
    $firstPageImages = getOption('images_per_page');
    }
    ?>
    `
  • `
    <?php
    if (getNumImages() > getOption('images_per_page')) {
    $_zp_conf_vars['images_first_page'] = getOption('images_per_page');
    $firstPageImages = getOption('images_per_page');
    } else {
    $_zp_conf_vars['images_first_page'] = getNumImages();
    $firstPageImages = getNumImages();
    }
    ?>
    `
  • acrylian Administrator, Developer
    Good that you solved it for your purpose. Zenphoto is quite flexible as you see,even if moving out of the "standard way" might cause some experimentation..;-)
  • Hi again - sorry for dragging this up but I felt I should keep it up to date in case for some reason someone benefits from this. As I've been developing my theme I ran into issues with the above. It breaks if there is no sub albums. This is how I have it now in album.php:

    `
    <?php
    $numsubs = $_zp_current_album->getNumAlbums();
    if ($numsubs !== 0) {
    if (getNumImages() > getOption('images_per_page')) {
    $_zp_conf_vars['images_first_page'] = getOption('images_per_page');
    $firstPageImages = getOption('images_per_page');
    } else {
    $_zp_conf_vars['images_first_page'] = getNumImages();
    $firstPageImages = getNumImages();
    }
    }
    ?>
    `
    This is what I have in the search.php for archive mode:

    `
    <?php
    if (!isArchive()) {
    if (getNumImages() > getOption('images_per_page')) {
    $_zp_conf_vars['images_first_page'] = getOption('images_per_page');
    $firstPageImages = getOption('images_per_page');
    } else {
    $_zp_conf_vars['images_first_page'] = getNumImages();
    $firstPageImages = getNumImages();
    }
    }
    ?>
    `
    Cheers!
Sign In or Register to comment.