issue with isImagePage() ?

vincent3569 Member, Translator
Hi

there is something I don't understand on Zenphoto version 1.4.2.2 [9450].

I have an album A which contains only subalbums (K, X, Y, Z).
Due to my configuration, I have pagination and I see K, X on the 1st page, and I see Y, Z on 2nd page.

For personnal needs, I need to evaluate isAlbumPage() on album pages.
In my case, on 1st page, isAlbumPage() = Null, and on the 2nd one, isAlbumPage() = 1.

Of course, I am sure that there is no picture under A, only subalbums.

This is an issue ?

Comments

  • vincent3569 Member, Translator
    sorry, I wrote a mistake, and you should read this :

    For personnal needs, I need to evaluate isImagePage() on album pages.
    In my case, on 1st page, isImagePage() = Null, and on the 2nd one, isImagePage() = 1.

    other information : If there is no pagination, isImagePage() = Null.
    So it seems to be an issue on isImagePage when there is album pagination.

    at least, isImagePage() should return a boolean, but that is not the case, and if there is no picture, isImagePage returns Null
  • `NULL` is indeed a boolean, same as `false` or `0` so I really do not understand your issue.
  • vincent3569 Member, Translator
    for me boolean contains `true` or `false` (0 or 1).

    but indeed, the issue is that in a paginated albums wich contains only subalbum, in the second page page isImagePage() returns `true`.
  • If you are going to write PHP (or C) code you better get used to the fact that a variable is `false` if it is `0`, `NULL`, or empty. Otherwise it is `true`.
  • vincent3569 Member, Translator
    never mind about boolean value, it is not the purpose.

    the issue is that in a paginated albums wich contains only subalbum, in the second page page, isImagePage() returns true.
    in that case isImagePage() should return false, 0, NULL, or empty, but not true.
  • It reports when a page might contain images. So if your albums do not "fill" the page then isImagePage will return true. Why are you testing this if there are no images?
  • vincent3569 Member, Translator
    in documentation, isImagePage returns true if there is image thumbs on album page (http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functionisImagePage)

    that is exactly what I want (and not have true if album page might contain images).

    I need that for displaying contextual help if there is image thumbs on album page (if isImagePage returns true).
  • Wete Member
    You could additional check if `getNumImages($_zp_current_album) > 0`
  • vincent3569 Member, Translator
    hi
    @Wete : thanks for you help
    I hoped you are true, but the tip doesn't work well.
    The contextual help is evaluated in my footer, wich is the same on each page of my site (gallery, album, image, news, and page).

    so getNumImages returns `Fatal error: Call to a member function getNumImages() on a non-object` if I am not on album page.

    I will have a look to have a workaround, but the simplest way is to solve the issue on the function isImagePage done for that, don't you think ?
  • Wete Member
    I am surprised that isImagePage() checks if the page /might/ contain images. I agree that this should be modified.

    Wete
  • acrylian Administrator, Developer
    @vincent: Then add a check for the page using `$_zp_gallery_page`.
  • Ok, it is changed in the nightly build.

    But the function is not intended for use except on album pages. It could add a check for that, but then everyone will have to pay the price for your desire. I think it better that you make the check before calling the function that it is on an album page.
  • Wete Member
    What I like most on ZenPhoto is that the developers accept criticism by the users and not reject issues as irrelevant. :)
  • vincent3569 Member, Translator
    @sbillard :
    I'm still surprised by some of your remarks.
    I try, as best I can, to contribute to project zenphoto.
    I reported bugs, made suggestions for improvements, themes, plugins ...
    Of course, it gives no privilege, but I will hope to find more listening.

    I do not report bugs to bother you but to contribute to make a better product.
    For your information, isImagePage() is only used on official themes stopdesign and effervescence_plus (used on albums and search page).
    So there was something going wrong with the issue that I have reported
    So, as usual : do like you want...

    However I have found a workaround for my own business :
    in my footer, I wrote that :
    `<?php if (($_zp_gallery_page == 'album.php') && (getNumImages() > 0)) {...} ?>`
  • acrylian Administrator, Developer
    @wete: I hope that was not ironic...

    @vincent: I think you misunderstood smy collegue. We really do appreciate your active reports and contributions. I don't know how you might think we weren't! Even if we don't agree always. But sometimes the doc comment can be wrong or the function is just not intended for what someone wants to use it (as originally in this case). So right on with your reports.

    Also we hesitate to change some things too fast for backward compatibility. That only standard themes use it says nothing about custom themes out there (there are surely sites that neither use official nor 3rd party themes but own custom ones). We are really concerned about backward compatibility as far as possible for our convenience.

    Your check above is exactly what I meant above.
  • Wete Member
    Acrylian, it was absolutely not ironic. sbillard wrote, the function has been changed in the actual nightly, and that pleases me.

    After reading the last posting of vincet I see, that my posting could be misunderstood.

    Wete
  • @vincent: What I have said is that I do not think it appropriate to add significant overhead to a function so that someone can essentially mis-use it. The function was intended to be used to tell if a page could display any images thumbs. We have enhanced it so that it will check the image count as well and report if the album page WILL display any image thumbs. But this test is costly if you are not on an album page so it seems inappropriate to add When it is just as simple for you to be sure your code is active only on an page that could display image thumbs [specially since it seems that is the only place you want it to appear]

    Much of Zenphoto is context sensitive. Theme writers need to be cognoscenteof the context or there will be errors.
Sign In or Register to comment.