How to use the Dynamic Albums feature September 08, 2008 / Updated: June 12, 2022
Dynamic album basics
Albums in Zenphoto are physical and based on a folder on the file system. Dynamic albums are albums created dynamically based on a search, so technically a saved search. Therefore they update themselves if the search returns new results. Dynamic albums cannot have subalbums unless these are part of the search results.
Dynamic albums are on the file system represented as a text file <albumname>.alb. The suffix is shown in the URL if there is a physical album of the same name, otherwise the suffix is omitted (1.4.3).
Note that usage of dynamic albums requires Cookies to be enabled in the visitor's browser to stay in search context.
Important note on image file names: With Zenphoto 1.4.6 the URL scheme of images within a dynamic album changed. Formerly they had the name of their real album in the image page URL. Now they have the name of the dynamic album. The benefit is that you now can link to an image within a dynamic album directly and behave like a real album.
This however introduces the limitation that you cannot use images with the same filename but from different real albums within a dynamic album anymore. Actually you can but it will confuse pagination links and thefore your users as these images will all have the same URL.
If you intend this feature be sure you use unique file names for all of your images within all albums.
Important SEO note to urls of items in dynamic albums: Due to the URL scheme noted above using dynamic albums can introduce SEO issues regarding duplicate content. Images now have no unique URL becuase they have their "real" URL in their "real" physical album and those in perhaps even several dynamic albums. To lower SEO impact it is strongley recommended to enable the html_meta_tags and its canonical URL option.
Creating a dynamic album
From a search
To create a dynamic album just perform a search.
- This will return a page with your search results. On that page (assuming you are logged in) is an admin toolbox link and clicking on that link will reveal a create album link.
- After you have clicked on that, you will be able to make an album out of your search. You can then set several options what to use to create the album (tags, title, descriptions etc).
- After that you can refine some search options and the title/name.
- You can also change its sort order within the other albums, just like with any other album. A dynamic album of course may be the subalbum to a physical album.However it naturally cannot have direct subalbums itself but the search result of course may contain albums if the search is set that way. Dynamic albums use other icons so you can identify them in the list.
- On the gallery itself the album is also shown like any other. Since they are "saved searches" you cannot sort its images manually though. You can however set general sort orders like by title, date etc.
Directly on the backend (since 1.4.8)
You can create a dymamic album directly on the album edit pages without a prior search by using the button of the same name.
To refine the dynamic album creation you somehow have to identify the pictures you want to collect. The simplest way it to give them a common unique tag. Then perform a search and proceed as described above.
Setting up the dynamic album context manually
As dynamic albums are saved searches you need to access the album page of the dynamic album to create this special context. From Zenphoto 1.4.3 on it is possible to manually set the context by using this code:
<?php zp_load_album('<your dynamic album name>'); prepareAlbumPage(); ?>
For the same reason you also cannot link directly to an image within a dynamic album as that will always get the image within its original album. To setup an image context - in this example the first - while staying within the dynamic album you additionally need to do:
<?php $firstimage = $_zp_current_album->getImage(0); $firstimagealb = $firstimage->getAlbum(); zp_load_image($firstimagealb->name,$firstimage->filename); prepareImagePage(); ?>
This text by www.zenphoto.org is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Code examples are released under the GPL v2 or later license
For questions and comments please use the forum or discuss on the social networks.