multi field search at Advanced Search

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mehmetbkm
User
Posts: 20

multi field search at Advanced Search

Post 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?


arbei
User
Posts: 9719

Post by arbei »

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


mehmetbkm
User
Posts: 20

Post 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;
        }
    }
}

arbei
User
Posts: 9719

Post 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.

Post Reply