Get album by tag?

Is there a function to get albums according to their tags? If I have four albums with a tag of 'favourite' for example, how could I retrieve just those four? I'm building a custom page, hence the request.

I had a look through the functions documentation but searching on 'tags' gives too many false positives as each function description has a tag.

Thanks,

Ed.

Comments

  • I guess I am confused. If searching for albums using just those tags gives you too many hits then there is nothing to be done as there are too many albums with those tags. How can searching tell what is wanted and what is not?

    Or perhaps you did not limit the search to just the tag field? I also really do not understand what you mean by "each description has a tag". Tags apply to objects, not fields.
  • You could possibly store a special tag for the albums, for instance on one of my themes I tagged my images as "featured" and they were pulled into a dynamic album that I used a random image call on.
  • acrylian Administrator, Developer
    You should limit the search options to albums and tags. Then you would get only those albums with those results. You can then even create a dynamic album (aka saved search) for that to create your custom page.
  • Thanks again for the quick responses. Sorry for the confusion, let me try to clarify.

    I've tagged four albums with a 'Europe' tag which works as expected - I can search for them using the search page, click on the tag etc and I get the correct four albums.

    What I'd like to do is create a custom page which gets those same four albums so I can display their titles in an unordered list, creating a summary page of albums per continent. This is a bit like the print_album_menu function but only for albums with a specific tag. I'm trying to replicate a page on my old site (http://www.thefunkysite.com/travels/Travels.asp) if that helps clarify?

    It's only when searching the function documentation (zenphoto.org/documentation/elementindex.html) for the keyword 'tag' that I get lots of hits, hence asking if you can help identify available functions for working with tags.

    I'd like to avoid a dynamic album if possible because my homepage shows all albums and I don't want these showing on the homepage.

    Thanks again,

    Ed.
  • acrylian Administrator, Developer
    The dynamic album is the easiest way to do this. Otherwise you will have to use the object model to setup searches direclty. If you don't publish the dynamic album it is not shown on the home page.

    Since you can direclty link to any unpublished item you also have your custom page actually. if you need another layout use the multiple_layouts plugin for example.

    Since it is an album you can also use the object model on a theme custom page to display.
  • Using a dynamic album but not publishing it is a good idea. I'll give that a go tonight - thanks.
  • Sorry but I'm still struggling. I've created a dynamic album but can't see what code I'll need on my custom page to display or query it. I've had a look but there's only one function for Dynamic albums (hasDynamicAlbumSuffix) and I'm not sure how to get the right album context.

    Can someone point me in the right direction?
  • acrylian Administrator, Developer
    If you can live with just a normal album page just link to it and you have a page with that.

    If you need a specific custom theme page with a specific layout your need to make the album current (there is a function for that named accordingly) on that custom theme page and then you can just use the next_album loop as on album.php. Alternatively you can use the object model directly.
  • I'm going to need a custom page because I'll want to get a few albums and query them for subalbums (ie one dynamic album for Europe, one for Africa etc).

    Acrylian's said there's a function to make an album current but I can't find it. Can anyone please give me a function name or ideally some code? All I want to do is retrieve five dynamic albums and list the names of the albums and subalbums (ie an index page). Surely it can't be that hard?

    I've tried looking through the function documentation but all the getAlbum functions seem to act on the current album (which I don't know how to set).

    I've read the object model introduction but it simply states that '$_zp_current_album is setup in album context as within the next_album() loop or on a theme's album.php'. I don't want to loop through all the albums, I just want to set it to a named dynamic album. I had a look at the print_album_menu.php code which uses getManagedAlbumList() but I think that returns an array of objects and I still don't know how to set the current album to one of those objects. I'm not fussed whether I use the object model or a prebuild function - whichever gets the job done is fine by me.

    Help please! It only took me a few evenings to get a new hosted site up and running with all my galleries imported and to modify the HTML/CSS but I've now spent four evenings making zero progress because I can't work out a couple of lines of code. I understand PHP, CSS, HTML etc but I'm struggling to understand the logic flow for Zenphoto. I'm getting to the point where I'll happily pay someone to do this for me as my wife is due with our first baby in three weeks and I won't have any time to spend on tweaking my website...

    I really do appreciate the quick answers everyone's given and I'm sorry if this sounds like a rant but I think sometimes the developers forget how much they know about Zenphoto and how hard it can be for a newcomer. Saying 'make your album current' is no doubt simple for you, but hours of searching forums and documentation for me! I'm serious about the payment too, within reasonable limits.

    Thanks,

    Ed.
  • acrylian Administrator, Developer
    I can understand you but we try to help to help yourself. It exceeds a little to literally take someone by the hand..:-)

    The function is named makeAlbumCurrent(). We try to name all speaking. You easily find it on our functions documentation if you follow the links and tips here: http://www.zenphoto.org/news/functions-documentation
    Tha function will setup the global $_zp_current_album.

    As already said the easiest is to link the album in question directly then all is already setup. You can link to any unpublished item (be it image, news or page) directly, it just does not appear in menus or loops.

    If you need another layout for that, try the multiple_layouts plugin to assign a specifically created album page layout.
  • Thanks again acrylian, I did look through the functions docs but must have missed that one (there are rather a lot of functions!). I was expecting it to be a 'setAlbum...' to match the 'get' naming pattern.

    I'm still stuck however. To use makeAlbumCurrent I have to pass an album object which means I need to retrieve the dynamic album first. Having looked previously the only function with 'dynamic' keyword is 'hasDynamicAlbumSuffix' and the getAlbum functions all seem to work on the current album, which I can't set. Dynamic albums don't seem to generate an actual folder structure either. Aaaarrgh! I'm sure once I've set the album to current I can manage the rest but everything seems to be geared around the idea you have an album in context. I think i must be missing some basic concepts because every step is not intuitive for me.

    Can you give me a code example for getting the dynamic album? I don't want to be led by the hand but neither can I spend days trying to become a full time Zenphoto developer. Do I need to run a search function and use GetAlbumList? I found an old forum post (five years ago) that that uses a mysql_fetch but I'm guessing that's no longer relevant.
  • acrylian Administrator, Developer
    I am sorry, I indeed forgot that setting up a dynamic album is a little more complicated than a static album as it needs another special environment because it is a saved search and also requires a specific cookie to be set.

    If you wish to create that environment you need to do:
    `
    zp_load_album();
    prepareAlbumPage();
    `
    Now you have the normal album environment and you can use the object model or the template functions as $_zp_current_album is setup.

    This is not possible on older Zenphoto versions than 1.4.3. Before it only works with static albums and this was added because I needed it as well. I will add this to the tutorial for dynamic albums.

    But let me repeat the question why you don't just link to the album as that does all this already.

    PS: Here is the updated tutorial: http://www.zenphoto.org/news/how-to-use-the-dynamic-albums-feature#setting-up-the-dynamic-album-context-manually
  • Thanks. I'm still running 1.4.2.4 so I'll have a go at upgrading the installation and trying the above code.

    I'm not linking to the dynamic album directly because I want to list a summary of several dynamic albums on a single page. Hope that makes sense. Have a great weekend,

    Regards,

    Ed.
  • acrylian Administrator, Developer
    Ok, then it makes sense if you cannot put them all into one album for that. Otherwise you could of course use the same measure to create a dynamic album with those dynamic albums, too.
Sign In or Register to comment.