problem with function getAlbumURL

ctdlg Member
edited June 18 in General support

Hello,

There is a bug with the getAlbumURL function in template-functions.php that appear only if :

  • some (at least one ) dynamic or standard album are in an album and image.php theme uses a link like

<a href="<?php echo html_encode(getAlbumURL($realalbum)); ?>" title="">my_link</a>

  • AND Options -> Theme -> Transition is set to "combined"

  • AND you reaach the image from a dynamic album

No problem if Options -> Theme -> Transition is set to "separate"
No problem if you reach the image from it's parent album !

I have removed this code to reach the realalbum in all cases !

if (in_context(ZP_IMAGE)) { $page = getAlbumPage($album); if ($page <= 1) $page = 0; } else { $page = 0; }

Because if the 2 above conditions are met, the page number of the real alum is too high, and error page is displayed.

Comments

  • acrylian Administrator, Developer

    I fear I don't understand the issue right now. Especially the "AND you reaach the image from a dynamic album" confuses me. Do you perhaps have link where to see the issue?

  • ctdlg Member
    edited June 18

    @acrylian
    I have removed the code, so real album is displayed correctly now.

    Nevertheless, visit this dynamic album:
    https://clatique.fr/multimedia/Nouveautes/

    Then choose
    Liffol le Petit, vue aérienne (S) (bottom of the page)

    At the bottom of the image page, a button link " Voir la galerie "
    It does work now, but with the original code, I got an error because of page 2 computed instead of page 1. There is no page 2 in the mentioned original album!
    As you can see, this album contains a sub album named Église Saint Remy.
    (yellow text on dark grey background thumb)
    As you can see, I use Options -> Theme -> Transition set to "combined"

    The button link from the image page did work if I set
    Options -> Theme -> Transition to "separate"

    There is no "Transition" test in the getAlbumURL function.
    This is why page number is wrong if "combined" is used with other (my AND lines) conditions.

    Problem appears only if you reach an image from a dynamic album.
    Because if you reach the image from it's original album, the getAlbumURL function DOES work.

    The getAlbumURL function does also work if no subalbum exists in the original album, even if you reach a picture from a dynamic album !

    This is why I used "AND" 2 times in my original message.

  • acrylian Administrator, Developer

    Since you are using a custom theme, I assume you have tested this with an official theme? This is always important to rule out that a theme does something wrong somehow like setting the images/albums per page manually somewhere bypassing the options. Instead of removing the lines in getAlbumURL() getAlbumPage() needs to be looked at which does the page number part you say goes wrong here.

    Anways, we'll have to try to reproduce this.

  • acrylian Administrator, Developer

    Haven't had time to reproduce anything but just to note instead of "hacking" core code I recommenend to use $realalbum->getLink() on your theme instead for the url of the album (assuming $realalbum is an album object).

  • ctdlg Member

    I have tried with your 1.5.8 basic theme and your template-functions.php file
    Same problem. (also solved with my template-functions.php file.)

    I have only added the button link to image.php file.
    Full code used in my image.php file is
    <?php $realalbum = $_zp_current_image->getAlbum(); ?> <div id="boutons-pages"> <a href="<?php echo html_encode(getAlbumURL($realalbum)); ?>" title="">Voir la galerie</a> </div>

    I will try your above code with your template-functions.php file.

  • acrylian Administrator, Developer

    We still have to investigate this. But the page number calculation apparently misses the "transiton" part of "items per page" here somehow. We will simplify the related default theme options anyway since the concept of "columns" was always a rather awkward workaround and is totally obsolete with especially responsive themes.

  • acrylian Administrator, Developer

    I could reprpduce this. The cause were actually neither getAlbumURL() nor getAlbumPage() but the image class method getIndex() which for an image of an dynamic album still used that instead of the real album passed to getAlbumURL().

    Fix is up on Github.

  • ctdlg Member

    Thank you very much !

Sign In or Register to comment.