My problem is a bit hard to describe, but I'll do my best. Please let me know if you need further clarification.
On my search page it displays the albums that match the search in a div and all of the images that match the search in another div. These divs are styled to clearly separate the images from the albums.
If there are no images/albums to display the corresponding div is not shown. I have used the following code to achieve this:
if(getNumAlbums() > 0){//print div and loop through albums}
and
if(getNumImages() > 0){//print div and loop through images}
This setup works as intended until the search results have to be split onto multiple pages, for example:
A search returns 10 albums and 50 images. All 10 albums are displayed on the first page along with 25 of the 50 images. The other 25 images are on the second page. The problem is when you go to the second page to view the last 25 images the albums div is still shown but it is empty (as all of the albums were displayed on page 1.).
My question is how can I stop the albums div being shown on the second page of the search results if there are no more albums to display i.e. the albums div will be empty?
Comments
The functions you are using are checking the album object not the page contents that is why it is probably not working. I think there is a pair of functions called isAlbumPage and isImagePage. Those might get you what you want, check the function docs.
isAlbumPage - "Returns true if this page has album thumbs on it"
Unfortunately isAlbumPage returns "true" on the second search page when all of the albums have already been displayed on the first search page.
`isAlbumPage` and `isImagePage` should actually also work in both contextes as theey use the functions above internally.
I did some testing (using both my custom theme and a copy of the "basic" Zenphoto theme) and found the isImagePage and isAlbumPage functions work (hides the div if no images/albums are to be displayed) unless I am using:
setOption('albums_per_page', XX, false)
And
setOption('images_per_page', XX, false)
However, both my theme and the "basic" theme work if I set these options through the Zenphoto theme options rather than using "setOption".
I guess I will have to use the theme options to set values suitable for the search results and override them wherever I need a different value. Thanks for all of your help, I really appreciate it
Maybe it is possible to set this via a filter earlier but I haven't investigated. Anyway, there are plans to allow this kind of setting differently. But that might take a while…