$_firstPageImages contains wrong values?

Hi there!

Is it possible, that $_firstPageImages contains wrong values if the sub-albums go over more than the first page?

I recognized this behaviour when checking out the search function and got 15 albums (12 are shown on each page) - so image thumbnails started on page 2.

As you know from http://www.zenphoto.org/support/topic.php?id=10327 I use fancybox for displaying the images, therefore I generate invisible links to all images of an album (or of a search result!).

You may see it here: http://www.musikverein-zunsweier.de/galerie/page/search/konzert/2

Klick the first image thumb and navigate to the image before (left) -> should be 181/181 not 9/181.

echo $_firstPageImages; returns 9 - which is the value of the images on the second page. Value should be -3.

Wete

Comments

  • :-(
    should be in "usage support" - sorry!
  • $_firstPageImages returns the number of images that are on the first image page (Which is not necessarily page 1 of the album.)

    There are two functions to help you know where you are:
    `isAlbumPage()` and `isImagePage()`
    There are no images on a page where `isImagePage()` returns `false`

    Note: both functions may return `true`, as on the transition page.
  • Thanks!
    I'll try my best.

    Wete
  • It works.

    `
    <?
    $albumseiten = getTotalPages();
    $aktuelleseite = getCurrentPage();
    $offset = floor(getNumAlbums() / getOption('albums_per_page'));
    if (($albumseiten-$offset > 1) AND ($aktuelleseite-$offset > 1)) {
    for($vorseite = $offset+1; $vorseite < $aktuelleseite; ++$vorseite) {
    $bilder = $_zp_current_search->getImages($vorseite-$offset, $_firstPageImages);
    $i=0;
    foreach ($bilder as $bild) {
    $bild = $bilder[$i];
    $imageobject = newImage($_zp_current_search, $bild);
    $bildnummer = $imageobject->getIndex()+1;
    ++$i;
    echo'getFullImage().'" title="getImageLink().'">'.$imageobject->getDefaultTitle().' ('.$bildnummer.'/'.$_zp_current_search->getNumImages().')">'."\n";
    }
    }
    }

    echo '
    '."\n";
    while (next_image()) {
    $c++;
    echo '
    '."\n";
    echo '
    getImageLink()).'">'.html_encode($_zp_current_image->getDefaultTitle()).' ('.imageNumber().'/'.getNumImages().')">';
    printImageThumb(getAnnotatedImageTitle());
    echo '
    '."\n";
    echo '
    '."\n";
    }
    echo '
    '."\n";

    if (($albumseiten-$offset > 1) AND ($aktuelleseite-$offset < $albumseiten-$offset)) {
    for($nachseite = ($aktuelleseite+1); $nachseite < ($albumseiten+1); ++$nachseite) {
    $bilder = $_zp_current_search->getImages($nachseite-$offset, $_firstPageImages);
    $i=0;
    foreach ($bilder as $bild) {
    $bild = $bilder[$i];
    $imageobject = newImage($_zp_current_search, $bild);
    $bildnummer = $imageobject->getIndex()+1;
    ++$i;
    echo'getFullImage().'" title="getImageLink().'">'.$imageobject->getDefaultTitle().' ('.$bildnummer.'/'.$_zp_current_search->getNumImages().')">'."\n";
    }
    }
    }
    ?>
    `
    Wete
  • BTW: `isImagePage()` returns TRUE on my Search results page 1 - where no image thumb can be found because of 15 albums in the search result.

    Wete
  • Doesn't do that for me. Where are you making the test?
  • I just added `<?php $abc = isImagePage(); echo 'Value for isImagePage: '.$abc; ?>` in search.php and searched for 'konzert' - as in the link above:
    http://www.musikverein-zunsweier.de/galerie/page/search/konzert

    On every page I got a '1'.

    You may check it now, it's visibily implemented.

    Wete
  • I have to correct myself:

    The computation of $offset is:
    `
    $offset = floor (ceil (getNumAlbums()/getOption('albums_per_row')) / (getOption('albums_per_page')/getOption('albums_per_row')));
    `
    Wete
  • I see it, but cannot reproduce it.

    Can you echo the values for:
    `
    getTotalPages(true)
    $_firstPageImages
    $_zp_page
    `
    These are the input to the computation.
  • Done.

    `
    echo '

    '.sprintf(gettext('Total matches for %1$s: %2$u'), $searchwords, $total).'
    isImagePage: '.isImagePage().', isAlbumPage: '.isAlbumPage().', getTotalPages(true): '.getTotalPages(true).', $_firstPageImages: '.$_firstPageImages.', $_zp_page: '.$_zp_page.'

    ';
    `
  • Wellyour value for `getTotalPages()` is clearly wrong. Somehow that calculation seems to think there is only one album page.

    I wonder what you get for these calculations in a standard theme? That is of course where I am testing things.
  • The documentation says:

    `
    getTotalPages [line 512]

    Returns the number of pages for the current object
    Parameters:
    bool $oneImagePage: set to true if your theme collapses all image thumbs or their equivalent to one page. This is typical with flash viewer themes
    `
    If I understood this correctly, '2' should be correct value when (true) is added: The first page only contains sub-album thumbs, image thumbs start on page 2, and if the theme would collapse all image thumbs to on page, they would be shown here.

    But I'll additional check it in default theme.

    Wete
  • OK, here are the results from Germany:

    If I ask for the value of getTotalPages(), it says 17. That is correct (Theme: MVZ). Values:
    isImagePage: 1, isAlbumPage: 1, getTotalPages(): 17, $_firstPageImages: 9, $_zp_page: 1

    Then I took the default theme and added the echo...
    Results:

    Page 1 (no images!):
    isImagePage: 1, isAlbumPage: 1, getTotalPages(true): 2, $_firstPageImages: 5, $_zp_page: 1

    Page 2 (albums + 5 images):
    isImagePage: 1, isAlbumPage: 1, getTotalPages(true): 2, $_firstPageImages: 5, $_zp_page: 2

    I suppose that '2' should be correct for getTotalPages(true). Without 'true' the correct value of total pages is shown.

    As you can see: isImagePage always returns '1'.

    Wete
  • I have more album pages than that. Maybe there is a problem with the specific case that you are seeing. I will see if I can discover something.

    [edit] Indeed there is a bug here. Fixed in the nightly build.
  • Thumbs up! :)
  • One last question: '2' and '3' were (in my case) correct for getTotalPages(true), right?

    Wete
  • That number should always be one greater than the number of pages for albums. I really did not verify your values. The fix involved not using `true` as the parameter value any more.
  • Then it was correct.
    Is it advisable to use nightly builds for non-experimental installations when everything else goes fine? (I do not need the getTotalPages-Function in my case.)

    Wete
  • The Trunk build contains only fixes to the released Zenphoto version, so by and large it should be fine to use anywhere. Of course, you should test first because sometimes things happen.
  • Thanks.
  • I checked the behaviour for `isImagePage` on a different installation of ZenPhoto (wete.org). I searched for `'e'`, what is quite stupid, but it leads to many results. ;-) I got 3 pages with albums, page 4 is mixed, page 5 ff. contains only images. Page 1 and 2 `isImagePage` returns `false` (correct behaviour). But on page 3 (only albums!) it returns `true`. In my first example (see above) there were only 2 pages of albums (page 1 pure, page 2 mixed), so I think, the error could be descriped as "works fine exept on the page BEFORE the first page with images".

    Now I will install the nightly build and check this again.
  • With the trunk nightly build 12-02-13 it's fine. :) Thanks!
  • But now there is another error:

    `Warning: array_slice() expects parameter 1 to be array, boolean given in /........./galerie/zp-core/class-search.php on line 1378`

    See:
    http://www.wete.org/galerie/page/search/e/4
    (at the bottom)

    I also checked it in the default theme: same error.

    Wete
  • Hmmm ... and now not reproducible. Maybe a caching behaviour? It was there, I swear!
  • acrylian Administrator, Developer
    Sometimes caches (browser and/or server) can play funny tricks...
Sign In or Register to comment.