How to exclude an album from search function ?

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 !

Tags:

Comments

  • acrylian Administrator, Developer
    edited November 6

    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.
    
  • ctdlg Member

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

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

  • acrylian Administrator, Developer

    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.

Sign In or Register to comment.