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:
`<?php while (next_album()): $c++; ?>`
`<?php if (getNumImages() !=0) : ;?>`
Here comes the album thumb...
`<?php endif; ?>`
`<?php endwhile; ?>`
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/romaWhen you click the navigation you can see six albums divided over 2 pages, while they really should be on one page...
TIA, Max
Comments
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.
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
* The `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
`
<?php if (function_exists('printAdminToolbox')) printAdminToolbox(); ?>
"><?php echo getBareGalleryTitle(); ?>
| <?php echo gettext("Zoekresultaten"); ?>
<?php $_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]);}
} ?>
<?php while (next_album()): $c++; ?>
<?php if (getNumImages() !=0) : ;?>
"><?php printAlbumThumbImage(''); ?>
">Album: <?php printAlbumTitle(); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php while (next_image(false, $firstPageImages)): $c++;?>
<?php printImageThumb(getBareImageTitle()); ?>
<?php echo getBareImageTitle(); ?>
<?php echo printImageDesc(true); ?>
<?php endwhile; ?>
<?php if ($c == 0) {echo "".gettext("Sorry, no image matches. Try refining your search.")."
";}
printPageListWithNav("« ".gettext("prev"),gettext("next")." »"); ?>
`
http://maccusfoto.nl/zenphoto/page/search/fields255/roma
http://maccusfoto.nl/zenphoto/page/search