Member:
Markus ⋅
Date: August 12, 2010, 11:18 PM
⋅ Subject: "Re: Hybrid Search"
Hybrid Search Explained
Pages are inside modules, but there are two kinds of content for each module — static and dynamic.
- Search Pages: Searches all the content you have created for your pages with the Builder's editor ("static content").
- Search Modules: Searches all content posted by users into your various modules ("dynamic content").
These two basic kinds of content are separately stored in the database, and therefore have separate searches. It also helps keep the webmaster's communication to visitors at better focus (and thereby site strategy better under control) on sites with lots of user-posted content.
To search both at once would require either an extension to the search class to do two queries at once and merge the results, or the creation of a separate master search index (which is on the roadmap along with multilevel cache and other performance boosters).
Member Module Search / Module Search Pages
Actually the Members module shouldn't be searchable from the global module search, because the member data set isn't symmetric with content in other modules, and therefore would neither return relevant results not provide a suitable interface.
To remove it from the global search dropdown, go to Admin CP > Modules > Members, and set "Add to global search?" to No. You should also do this for Admin module and all other modules without any active content. (Disabling a module effectively accomplishes the same.)
The blank middle-area in a page simply means that no layout has been defined for it. There is none for Members module because it isn't supposed to be within global search.
The same post_search page exists in all modules with searchable content, and regardless of which module you search in, the query is directed to the search page of the module selected in the dropdown. (Choosing "Global" and "-" search across all allowed modules and lead to the search page in your Site module.)
Therefore, you can also customize the search result formats on a per module basis if you want. For example, you could choose image results for gallery search, and summary texts for blogs, instead of the default "Search" format used for all search results.
Customizing Search Forms and Scopes
If you want to customize the search forms, they are editable in skin_search.php. You can add in searches for any fields that exist in the database for the content type you want to search.
If you want to create more possible search criteria for the currently available content, look at /core/layout_grid.php and the following section as an example:
$grid['post']['search']['post_id'] = "post_id = '[[KEYWORDS]]'";
$grid['post']['search']['post_name'] = "MATCH (post_name) AGAINST ('[[KEYWORDS]]' IN BOOLEAN MODE)";
$grid['post']['search']['post_location'] = "MATCH (post_location) AGAINST ('[[KEYWORDS]]' IN BOOLEAN MODE)";
$grid['post']['search']['post_people'] = "MATCH (post_people) AGAINST ('[[KEYWORDS]]' IN BOOLEAN MODE)";
$grid['post']['search']['post_caption'] = "MATCH (post_caption) AGAINST ('[[KEYWORDS]]' IN BOOLEAN MODE)";
$grid['post']['search']['post_description'] = "MATCH (post_description) AGAINST ('[[KEYWORDS]]' IN BOOLEAN MODE)";
$grid['post']['search']['post_text'] = "MATCH (post_name, post_caption, post_description, post_text, post_tags) AGAINST ('[[KEYWORDS]]' IN BOOLEAN MODE)";
If you wanted to for example create a new search that lets you pick posts with a certain rating, you could add in an input field with post_date, and add a criteria like below into your grid:
$grid['post']['search']['post_rating'] = "post_rating = '[[KEYWORDS]]'";
Whatever works after WHERE in regular MySQL queries will work in the above, so you can create whatever search criteria you want to.
Member custom profile sets haven't been mapped into the layout grid or search options yet (coming up), but the logic in action in the layout grid works for creating builder extensions and search criteria for any table in the database.