How to add a button in a dynamic album ?

Hello,

I would like to add a button in image.php that would only appear on dynamic pictures (a picture chosen from a dynamic album)

This button would be a link to the standard album where the picture has been published.

Example :
"my-picture" is published in "my-album". A tag is set and used in "this-dynamic album"
"my-picture" can be seen in "this-dynamic album"
The button that has to be displayed on "my-picture" page, accessed from the dynamic album should point to "my-album".

Sorry if this feature has already been discussed, my search function gave me no result.

Generally speaking, this could be a nice possibility for Zenphoto.

Thanks in advance.

Comments

  • acrylian Administrator
    edited February 11

    All possible you have to use the object model. Knowledge about PHP object orientation required:

    On image.php use something like this if the image is directly within the dynamic album:
    if($_zp_current_album->isDynamic()) { //here do whatever you like to do. // $_zp_current_album->getLink() gets the URL to the dynamic album and not the real album the image is in and $_zp_current_album->getTitle() the title for display. }

    A basic example. The above might not work as expected for images within albums that are also results of the dynamic album (search).

    To get the real album the image is in use:
    $realalbum = $_zp_current_image->getAlbum();
    Then use the same methods as above for link and title. On images in real album context both albums would be the same.

    Basics of the object model here:
    https://www.zenphoto.org/news/zenphotos-object-model-framework/
    Info on the classes on the functions documentation or within the files itself

  • ctdlg Member
    edited February 12

    Thanks acrylian.

    This code:
    <?php if($_zp_current_album->isDynamic()) { $realalbum = $_zp_current_image->getAlbum(); ?> <a href="<?php $realalbum ?> " title="Origines" >Galerie parente </a> <?php } ?>
    returns the same dynamic album image link, not the original album link.

    The "if" function does work : no link on real album pictures pages.

    I had a look to your "Basics of the object model " page, but your code is OK, so, I do not understand what is wrong !

  • fretzl Administrator
    edited February 13
    <?php if ( $_zp_current_album->isDynamic() )  {
     $realalbum = $_zp_current_image->getAlbum(); ?>
     <a href="<?php echo html_encode(getAlbumURL($realalbum)); ?>" title="Origines">Galerie parente</a>
    <?php } ?>
    
  • Thank you fretzl, it does work.
    I understand now a bit more Zenpage code !

  • acrylian Administrator

    Or $_zp_current_album->getLink() as I mentioned above.

  • ctdlg Member

    Hello,
    can we also add this button on search result image pages ?

    <?php if ( $_zp_current_album->isSearch() ) ... etc ...
    does not work !

  • acrylian Administrator
    edited 9:28AM

    $_zp_current_album->isSearch() does not work because it does not exist.

    To find out if an album is a dynamic album you have to use if($_zp_current_album->isDynamic()) { … } as noted above.

    The plain images result pages are not within an album context but in search context. To find ouf it you are on the search pages you can use if($_zp_gallery_page == 'search.php') { … } or also If(in_context(ZP_SEARCH)) { … }.

Sign In or Register to comment.