Hello,
Zenphoto is great, I use it since a few years and really enjoy it.
I'm currently building a new site. On the gallery of this new site, I woud like to show the 12 last uploaded images in an album.
I use the function printLatestImagesByDate() to do that and it works well.
When I'm on the image on the image.php file, and come from the last images album, I would like to put link for the visitor to get directly back to the album of the last images, but I don't know how to do that. Idem for the next and previous image link.
Currently, when I use the navigation of the image.php page, it does get back to the original album the image was uploaded to.
For the link back to the album, I currently use this function I've made :
function getParentSearchURL()
{
global $_zp_gallery, $_zp_current_search, $_zp_current_album, $_zp_last_album;
if (in_context(ZP_SEARCH_LINKED)) {
$page = $_zp_current_search->page;
$searchwords = $_zp_current_search->getSearchWords();
$searchdate = $_zp_current_search->getSearchDate();
$searchfields = $_zp_current_search->getSearchFields(true);
$search_album_list = $_zp_current_search->getAlbumList();
if (!is_array($search_album_list)) {
$search_album_list = array();
}
$searchpagepath = getSearchURL($searchwords, $searchdate, $searchfields, $page, array('albums' => $search_album_list));
$dynamic_album = $_zp_current_search->getDynamicAlbum();
if (empty($dynamic_album))
{
return $searchpagepath;
}
}
return null;
}
How to build the link?
Thank you by advance,
Xavier
Comments
Problem is that you need to pass to `image.php` where you came from. The image page cannot know that. So probably by appending `&source=index.php` to the url if `index.php` is the page with the latest images. (don't forgot securing the $_GET var before using it!).
Then you can add a check for that on `image.php` and build a link to return if needed.
If that is too much coding for you maybe it would be easier for you to just use a dynamic album sorted by date (well there is then no limit unless you code something). Then the album to return it is naturally automatically the dynamic album.
Actually, I don't know how to code something to limit the search results to a limited number of images. I've made some research on the forum, but didn't find a real way to do it. I don't know if you have a way to do that? I'll try by myself.
Thank you again.
Would a code that break the loop next_image() at an iteration (ie 12 or 20 images) work?
I was thinking about this code :
<?php $limitnumber = 0;
while (next_album()) { ?>
<?php if ($limitnumber==12) {break;}
}
?>
Yes, you can limit the number of images that way in an album. But if you do that on your theme's album.php you will do this for any album regardless if real or dynamic. Add a check like
`
if ($_zp_current_album->name == '' && $limitnumber==12)
{ … }
`
The name is generally what you see in the url of the album. On a dynamic album typically ' ' `.alb` and it includes possible parent albums.
Or you should extend your theme using this plugin:
http://www.zenphoto.org/news/multiple_layouts
The code :
<?php $limit = 0
while (next_image()): ?>
<?php if ($limit==6) {break;}
$limit++; ?>
<?php endwhile; ?>
does work well for limiting the number of thumbs to 6 in the dynamic album page, but each pages has now 6 thumbs. It does not limit the effective number of image of the dynamic album (by navigating inside this album, I've all the images, not only the 6 last I want, considering they're sorted by date). So I'm searching a way to limit the number of image in the dynamic album, wich is equal to limit the number of results given by the search loop (or filtering the 6 last results of the search). Is there a way to do that?
Thank you again.
My code was meant to give you a clue to limit something to one specific album. You have of course do do more custom theme coding like disabling the page navigation itself so you get only one page.
As you will hopefully understand I cannot provide a complete solution for your specific problem here. That exceeds the possibilities of this forum. If you wishing to dive deeper see the tutorial about the theming basics first and then look at the object model tutorial. Your will probably have to invest a bit of time.
I've finally solved my problem by adding a variable to the image url when I come from the dynamic album. I just made the navigation commands (next image) disapear from the page when the page show the image and the variable reach #6. It does works well and give the illusion the dynamic album is limited (just by making impossible to navigate further in the search results).
I'm sure it is a bit porcinet and it is certainly not conventional, but it does work... And I think I can use that to limit every search results.
Thank you again. I'll sure show my site here when it will be completely finished. Thank you for Zenphoto.
Xavier