Sitewide Search

Allmice CMS Classic Edition has a search module, which allows for example to search for Page module entries in body area, which include certain keywords.

Not only Page module entries can be searched. The Search module is quite abstract and very flexible allowing to search for entries from any database table column of the web site.
If you wish to do so, then first you should add through Search module a type for such search.

After installing Classic Edition, there is already one default search type available - this is the above mentioned example case "Page body area".


1. How to search?

There are two methods in Search module for searching:
1) index method, where you can choose the search type from drop-down menu (URL: [path-to-your-site]/search);
2) list-by-type method, where the search type information (id) is in URL.
For example you can quickly start searching for Page module entry content going to URL
[path-to-your-site]/search/list-by-type/1.

Do not forget to give access right for these methods by the roles, which users you are planning to allow searching for.
To do this, go to URL: [path-to-your-site]/system-manager/manage-access
Select module: Search; Select the role, tick the corresponding methods and click "Save changes".

If you type keywords to search form field without quotes and without double quotes, then spaces between words are treated as wild characters (spaces are meaning then zero or more characters between the words). If you write the words in search form area between quotes or double quotes, then exact phrase will be searched, where spaces are part of the phrase. This is similar to the way, how also search engines usually are interpreting the search form content.


2. Simple Search form with magnifying glass icon

You have probably noticed on many web sites a search form field with magnifying glass icon.
Allmice CMS Classic Edition Search module allows quickly to add to your web site such search form too. The search form can be added through search block, which shows a single form text field with magnifying class icon.
This search field will search by default for Page module content and after submitting the keywords in this search field you will be redirected to [path-to-your-site]/search/list-by-type/1, which shows also the search result. Below it is explained, what to do if you wish to use search field for some other search type.
If you wish to use the search block on your website, then there is of course the condition, that the theme, which you are using, must support searchArea region (all themes provided with Classic Edition are supporting it).


3. How to add search form field (search block) to your website ?

Add the following block, and search form should appear after this on your website.
Go to URL: [path-to-your-site]/block/add and add a block with following details:
Block code: searchBlock
Building module: GlobalCore
Type: uriBased
Building method: buildSearchBlock
Region code: searchArea
Access right for roles: admin, anonymous, authenticated
Rank: 1
Path: modules/Search/Model/SearchBlock.php
Block status: Active

There is also a configuration value to determine, which search type will be used for the search block.
If you wish, that search block would search from another table and field, than mod_page table body field, then change this config value.
To change this config value, go to URL: [path-to-your-site]/admin/list-config.
Select module: Search; Select type: searchBlock. From the table click Edit link in row, where uri is searchType.

After installing a new website, there will be a search type for page body content by default. Because of the way, how website is installed, the table field for the default search type will be empty.
If you wish to use the default search type, then check, that this form field is not empty.
Go to URL: [path-to-your-site]search/edit-type/1 and write to the "Table name" form field "mod_page".
If you wish, that last edited search result will be shown in first order, then write on the same page to the "Order sorting clause" form field "edited DESC". This assumes, that configuration value accessRightMethod (module App, config type paginator) is skip&order as it is by default.


4. How to customize instructions or other phrases of the Search form field?

The default instructions at the search form fields in URLs of the searching methods may seem a bit long. These instructions are just explaining how the content of the search field will be interpreted.
You can customize this guidance text in a way as you wish for the visitors of your web site.

Go to URL [path-to-your-site]/language/list-phrases.
Choose module Search and language English.

Look in the table at the rows, where Specific name is "indexEvent" and Uri is "guide/searchPhrase" or for the other method, where Specific name is "listByTypeEvent" and Uri is "guide/searchPhrase". Click edit link in these rows, if you wish to change these phrases. Through this table you can change also other phrases, which are related to Search module (which should be quite self-explanatory).


5. How to customize lists of search results?

The way how content will be searched using Search module and how search result will be displayed depends very much on App module's paginator configuration values.

Below are some instructions, what such configuration values are meaning and how to customize them to change search result.

To edit these paginator configuration values go to URL [path-to-your-site]/admin/list-config.
Select module: App, Select type: paginator.


5.1. Configuration value accessRightMethod

This configuration value determines how to display paginator search result for content, for which current user role has no access right.
This configuration value determines also, how the SQL queries for the search result will be composed.

The reasons, why to change this configuration value, are following:
1. Making the search result more or less user-friendly.
2. Making the searching process faster or slower (performance time).

Possible values are skip, skip&order, empty and full. If the value would be something else than those possible values, then the default value skip&order would be used.

How to show content with no access right? (User-friendliness)

Value skip will not show the result without access right at all; empty shows such result as empty rows; full shows it in the same way as other result, but clicking on search result link user would still not see the content; skip&order (or any unknown value) is similar to skip, but supports ordering search content.

Multiple easier SQL queries versus few complex SQL queries (Performance time)

Depending on the amount of entries in database and how many search results are displayed on one page, using different access right methods, may make the search process faster or slower.

The accessRightMethod values skip, empty or full are making simpler SQL queries compared with method skip&order. In those cases only more relevant data from database will be fetched, but there are much more SQL statements to get result from database. The more result links will be displayed on one page, the more SQL statements will be done (see paginator configuration value itemsOnPage).

The accessRightMethod value skip&order is making only two more complex SQL queries. In that case more redundant data from database will be fetched compared with other methods, but there are very few SQL statements to get result from database.

Support of Additional where clause for search types

The values skip, empty and full are supporting custom additional where clause for search types' SQL queries, which can be saved for a search type using Search module's add-type and edit-type methods. The value skip&order is not supporting such additional where clause - it would ignore it.

Support of content ordering/sorting for search types (User-friendliness)

The value skip&order is supporting order clause for search types' SQL queries, which can be saved for a search type using Search module's add-type and edit-type methods. The values skip, empty and full are not supporting order clause, which would be ignored in those cases.


5.2. Other paginator configuration values

The other paginator configuration values are: aliasCheckSwitch, displayPaginatorSwitch, itemsOnPage, maxRanges. These configuration values are easier to understand. Please click Edit links to read the descriptions of them to better understand, what they are doing.