ZenphotoCMS Forum
How to exclude an album from search function ? - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: How to exclude an album from search function ? (/thread-14073.html)

Pages: 1 2


How to exclude an album from search function ? - ctdlg - 06-11-2025

Hello,

I use the same Zenphoto cms for pictures (PC,tablets, smartphones) and VR headsets.
Using a VR headset ? you are redirected in the VR album, with all sub-albums available.
You cannot enter the VR section if you use a Pc/tablet (smartphones are OK in VR with a cheap headset)

Can I alter the search function so that the VR album + sub-albums are excluded from results ?
(no search page in VR section)

Thank you in advance !




How to exclude an album from search function ? - acrylian - 06-11-2025

While the searchEngine class has a property for that it for some reason cannot be set directly being protected.

Thte searchform function has only a parameter to set where to search but not to exclude.

I had to look myself: A small not so elegant workaround seesm to work by re-creating a new searchEngine object. So on your search.php try this right before all the search code:

//search takes parameters by POST/GET queries on object creation
$_REQUEST['excludealbums'] = 'youralbumname'; // comma separated list of album names to exclude
$_zp_current_search = new SearchEngine();
// normal search.php code here.



How to exclude an album from search function ? - ctdlg - 06-11-2025

Thank you so much, it works perfectly.
My problem is solved.

That question and your response could help some other Zenphoto users !




How to exclude an album from search function ? - acrylian - 06-11-2025

I probably just found the more elegant way without neeeding to overwrite the existing search object:

 $paramstr = 'excludealbums=orientation'; 
 $_zp_current_search->setSearchParams($paramstr);

I was not sure if setting that would clear any other search params submitted already but seems to work for me, too.




How to exclude an album from search function ? - ctdlg - 22-01-2026

A new question about search and Zenphoto :
can we clone the search.php file so that we can perform a search on my album that is exluded from standard search ?
If yes, I would add a search button on the page of that album ( i would also exclude all other albums )
I tried without success, probably beacause search.php uses template functions.




How to exclude an album from search function ? - acrylian - 22-01-2026

can we clone the search.php file so that we can perform a search on my album that is exluded from standard search ?
If yes, I would add a search button on

No, as that is what serves the results. All theme files "use" template-functions as that is what "runs" the theme ;-)

You of course have to use the function for the search button. And that has a objectlist parameter to limit search:
https://docs.zenphoto.org/1.6.x/namespaces/default.html#function_printSearchForm




How to exclude an album from search function ? - acrylian - 22-01-2026

The doc is not clear about $object_list I think. You use it this way:

 $object_list =  array("albums"=>array('albumname', 'another-albumname', ...))

You could run into problems if that album is excluded on the search.php page as well. So you possibly need to the check parameters you recieve there to override the exclusion on that occasion.




How to exclude an album from search function ? - ctdlg - 23-01-2026

I do not fully understand what I can do.
My website is divided in 2 main parts :
Pc, smarphones and pads.
Vr headsets.

Right now, We can search within the PC section.
The VR album is excluded from this search thanks to your advice.

To have a search within the VR section that excludes the PC section, what do I need to change or add ?
See https://clatique.fr




How to exclude an album from search function ? - acrylian - 23-01-2026

You need to add a check on what album (and/or subalbum) you are and add the search form to include or exclude that album.

Since the search form passes the query to the search page you need to check there what you request. if you there hardcode an exclusion for an album you need to override that here if you actually want to search within that album.

Sorry this is a bit more advanced stuff.




How to exclude an album from search function ? - acrylian - 23-01-2026

If you use this check on your search.php page:

$paramstr = 'excludealbums=albumname_to_exclude'; 
$_zp_current_search->setSearchParams($paramstr);

Right before you need to check if you request that album you excluded.

if(!in_array('albumname_to_exclude', $_zp_current_search->album_list)) {
   $paramstr = 'excludealbums=orientation'; 
   $_zp_current_search->setSearchParams($paramstr);
}

This is just off hand. I have not tried this or checked the structure of the $_zp_current_search->album_listarray but this should give you an idea.