Hi, I am trying to theme a stockphoto site with ZenPhoto.
I have many subalbums, and the thing is that when I do a search, I don't want the albums with no images in them to show up in the search page.
I actually managed to do that in this way:
Here comes the album thumb...
But the problem is that I configured my theme to show six albums per page. But on the page is only two albums visible. The other four albums (with no images in them) just seem to occupy empty space. How can I fix that ?
This is the site as it is now:
http://maccusfoto.nl/zenphoto/page/search/fields255/roma
When you click the navigation you can see six albums divided over 2 pages, while they really should be on one page...
TIA, Max
You will have to handle the pagination yourself since Zenphoto does not know you are not going to display some of the albums.
I have not tried the following, but think it would work.
Place the code before your while (next_album()) loop.
$_zp_albums = $_zp_current_search->getAlbums(0); foreach ($_zp_albums as $key=>$albumname) { $album = new Album($_zp_gallery, $albumname; if ($album->getNumImages() == 0) { unset($_zp_albums[$key]); } }
Then use the normal next_album() loop. The above code will remove all albums from the cache array which have no images. The next_album() loop uses the cache array if it is populated.
Thanks for your reply,
This code works!
But:
The albumname has now disappeared (I use printbreadcrumb).
When I use the searchbutton without putting text in the searchbox it generates an error:
Notice: Undefined variable: albumname in /storage/mijndomein/users/041181/public/sites/www.maccusfoto.nl/zenphoto/themes/maccus/search.php on line 40
while (next_image) loop below the album loop now generates an error:Fatal error: Call to a member function isDynamic() on a non-object in /storage/mijndomein/users/041181/public/sites/www.maccusfoto.nl/zenphoto/zp-core/template-functions.php on line 1681
Well, this code kind of messes with the normal Zenphoto flow of things. For the breadcrumbs, I would guess it would work if you print the breadcrumbs before invoking this code. For the search error, you will have to put some code in to be sure that the search returned something (the $zp_albums) is not empty.)
Well I solved the albumtitle issue, but my PHP coding abilities are too limited to fix the search error. Does anyone else have a solution maybe ? My search.php:
`
|
Stock foto database. Voer een zoekterm in...
Album: