Page 1 of 1

multi field search at Advanced Search

Posted: Sat Jul 13, 2024 4:27 am
by mehmetbkm

In my database, I have fields named 'Author 1', 'Author 2', 'Author 3', 'Other Authors', 'Contributors', 'Editors', and 'Translators'. When I perform a search from one of these fields in the 'Advanced Search' section, I want the search to be conducted across all these fields and return the relevant results. Is this possible?


Re: multi field search at Advanced Search

Posted: Sat Jul 13, 2024 9:32 am
by arbei

You may want to elaborate "search to be conducted across all these fields and return the relevant results".


Re: multi field search at Advanced Search

Posted: Mon Jul 15, 2024 12:49 am
by mehmetbkm

When I enter a search term in the 'Author 1' field in the advanced search Panel, I want the system to simultaneously search through all the following fields: 'Author 2', 'Author 3', 'Other Authors', 'Contributors', 'Editors', and 'Translators'. For example, if I search for "John Doe", I want the search to return all records where "John Doe" appears in any of these fields.

I use this code but it doesn't work

function Recordset_SearchValidated() {
    if ($this->isSearch()) {
        $searchTerm = trim($this->author1->AdvancedSearch->SearchValue); 
        if ($searchTerm != "") {
            $this->author1->AdvancedSearch->SearchValue = $searchTerm;
            $this->author2->AdvancedSearch->SearchValue = $searchTerm;
            $this->author3->AdvancedSearch->SearchValue = $searchTerm;
            $this->other_authors->AdvancedSearch->SearchValue = $searchTerm;
            $this->editors->AdvancedSearch->SearchValue = $searchTerm;
            $this->translators->AdvancedSearch->SearchValue = $searchTerm;
            $this->contributors->AdvancedSearch->SearchValue = $searchTerm;
        }
    }
}

Re: multi field search at Advanced Search

Posted: Mon Jul 15, 2024 8:51 am
by arbei
  1. Remove isSearch() because the server event is fired for search only.
  2. Make sure other fields are also enabled with Advanced Search, otherwise your code won't work.