print a link to a specific album

vincent3569 Member, Translator
hi,

is there a function to print a link to a specific album ?
I found printAlbumLink on documentation (http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functionprintAlbumLink) but it's only for current album.

Comments

  • acrylian Administrator, Developer
    Yes, via the object model you can do everything. See the album class.
  • vincent3569 Member, Translator
    maybe, I have something before my eyes, but I can't see anything about my request.
    I have an album name (or the directory for an album), is there a function ti print a link to this album, anywhere in my theme (footer, header,...)
  • acrylian Administrator, Developer
    Create an object of the album and use the album class method
    http://www.zenphoto.org/news/zenphotos-object-model-framework#creating-a-new-object
    http://www.zenphoto.org/documentation/classes/Album.html#methodgetAlbumLink

    Of course the gallery object is available already in `$_zp_gallery`.
  • vincent3569 Member, Translator
    thanks acrylian
    in other words, there is no other way to print an album link, without creating album object?

    The link will be in my header, or my footer, so it will be present on all pages of my site: I have to create object at each page reload?
    I'm not sure that this solution has the best performance on the server side, don't you think ?

    Is there no static method which allows to not create an object every times ?
    something like
    `Album::printAlbumLink('root_to_album)`
  • acrylian Administrator, Developer
    No, we don't have such a function. But - I forgot the obvious way myself - album links are quite simple so you can alway create a link manually like `echo WEBPATH.'/'` (modrewrite). That is what we do on our main nav. A function would be a bit overload.

    So if you don't need anything else of the album like title or tags or else to display, that is the way.

    For Zenpage items there are such links because of the keyword "news","news/category" and "pages" and also the custom pages "page/" so they update automatically in case the url structure changes.
  • vincent3569 Member, Translator
    of course, I can write something like that in the code
    `Album Name`
    but with such a function is supposed to know if there is mode rewrite, or what is the albums structure.
    so it would be more simple to have a function to avoid to rewrite some code if something changes somewhere else.
  • There is a mod rewrite function: `rewrite_path('`album name`', 'index.php?album=`album name`')`

    Static album methods could not work anyway. A static object has no unique content, so would not have the album name. The only way to get that kind of information is to instantiate the album.
Sign In or Register to comment.