![]() |
|
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) |
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. Can I alter the search function so that the VR album + sub-albums are excluded from results ? 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:
How to exclude an album from search function ? - ctdlg - 06-11-2025 Thank you so much, it works perfectly. 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:
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 : How to exclude an album from search function ? - acrylian - 22-01-2026
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: How to exclude an album from search function ? - acrylian - 22-01-2026 The doc is not clear about
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. Right now, We can search within the PC section. To have a search within the VR section that excludes the PC section, what do I need to change or add ? 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:
Right before you need to check if you request that album you excluded.
This is just off hand. I have not tried this or checked the structure of the How to exclude an album from search function ? - ctdlg - 27-01-2026 Sorry for late reply ! if(!in_array('albumname_to_exclude', $_zp_current_search->album_list)) { I understand the principle, but even after correcting the code, the album I'm searching for isn't being taken into account. It's as if the parameter isn't being retrieved on the search.php page. How to exclude an album from search function ? - acrylian - 27-01-2026 As mentioned the code above was quickly off hand and not tested as I had never to try this. Best you review the log to see what the error is. Did you actually also modify the search form function paramater on the specific album that is otherwise exclude? If not it is of course not passed to check at all, too. I will see if I get the chance to try myself the next days. How to exclude an album from search function ? - ctdlg - 14-03-2026 Here's my solution: // 1. First, we manage the session And search.php: if (session_status() == PHP_SESSION_NONE) { session_start(); } // Definition of exclusion according to the current album $_zp_current_search = new SearchEngine(); Finally, album-vr.php: if (session_status() == PHP_SESSION_NONE) { session_start(); } This way, I can perform as many searches as there are use cases across different areas of my site, including individual pages! How to exclude an album from search function ? - acrylian - 14-03-2026 Sorry, I didn't get around to test the code above I suggested at all… If I see right, you are "mis-using" the $_SESSION superglobal like to a cookie to know where the search request came from? Interesting!As usual whatever fits works ;-) How to exclude an album from search function ? - ctdlg - 15-03-2026 Yes, I'm repurposing the session's primary function! |