Search
CMS Builder makes it easy to develop custom search engines quickly.
Search Field Format
Section titled “Search Field Format”You can create a basic search engine by specifying the field name you want to search, followed by the search type, and incorporating that into a URL or search form.
| Format | Search Type | Notes |
|---|---|---|
fieldname | Exact match | Entire field value must match (case-insensitive). For multi-value list fields only one of the field values must match. |
fieldname_match | Exact match | Same as above. |
fieldname_keyword | Contains keyword | Field value must contain the keyword (case-insensitive). |
fieldname_prefix | Starts with | Field value must start with the keyword (or letter). |
fieldname_query | Matches query | Allows google-style query searches such as: +dog -cat "multi word phrase". Only records matching EVERY word or quoted phrase are returned. Words or phrases that start with - mean “must not match”. Plus is optional and not required. |
fieldname_empty | Matches blank fields | Matches fields that are blank (""). Example: email_empty=1 |
fieldname_min | Minimum value | For numeric searches (can also be used for date searches if the date is specified as YYYYMMDDHHMMSS; non-numeric chars are ignored). |
fieldname_max | Maximum value | For numeric searches (can also be used for date searches if the date is specified as YYYYMMDDHHMMSS; non-numeric chars are ignored). |
fieldname_year | Year number | For date searches. |
fieldname_month | Month number | For date searches. |
fieldname_day | Day of month | For date searches. |
fieldname_match[] | Multi value OR search | To do an “OR” search for multiple values add [] after the fieldname and search type, eg: ?name_match[]=joe&name_match[]=bob |
Additional date search details:
- The automatic
createdDateandupdatedDatefields support date searches (_min,_max,_year,_month,_day) even though they aren’t regular date fields. - For
_min/_maxsearches on date fields, an 8-digitYYYYMMDDvalue is expanded to cover the whole day:date_min=20250101matches from the start of January 1st anddate_max=20250101matches to the end of it.
Basic URL Search
Section titled “Basic URL Search”You can create a special link that lists only specific records by adding ”?” after your URL, followed by search conditions (fieldname=value).
Example: listViewer.php?color=blue
Combine multiple search conditions with ”&”.
Example: listViewer.php?color=blue&size=XXL
If a where clause is also specified in the list options, the two are combined. Records must match both the where clause and the search conditions: (where) AND (search).
Example: category pages
Section titled “Example: category pages”With articles holding a categoryNum list field populated
from a categories section, link each category to the article list filtered
by its record number:
<?php foreach ($categoriesRecords as $category): ?> <a href="articleList.php?categoryNum=<?php echo $category['num'] ?>"> <?php echo htmlencode($category['title']) ?> </a><?php endforeach ?>No extra code is needed on articleList.php: ?categoryNum=3 filters the
results automatically. To show the current category’s name as a heading, use
the :label pseudo-field from any matched record:
<?php if ($articlesRecords): ?> <h1><?php echo $articlesRecords[0]['categoryNum:label'] ?></h1><?php endif ?>Multi-field Search
Section titled “Multi-field Search”You can search multiple fields as easily as one field. Create a comma-separated list of fields followed by the search suffix.
Example: articleList.php?title,summary,content_keyword=Vancouver
Searching Joined Fields
Section titled “Searching Joined Fields”When a viewer uses the leftJoin viewer option, columns from the joined tables are searchable by their qualified names. Since PHP converts dots in incoming parameters to underscores, write the table and field separated by an underscore: ?brands_name_keyword=acme searches the joined brands.name column.
Custom Search Forms
Section titled “Custom Search Forms”Create search forms by naming the form fields after what you want them to search. Here is a simple search form that searches the title field for a keyword:
<form method="POST" action="/path/to/your/listViewer.php"> <input type="text" name="title_keyword" value=""> <input type="submit" name="submit" value="Search"></form>Alternative Search URLs (Advanced)
Section titled “Alternative Search URLs (Advanced)”Many servers support having extra “Path Info” after the URL like this: viewer.php/size-3/. This makes it appear as if a page or directory exists even if it doesn’t, and is great for search engine optimization.
The format is the same as for basic URL searches except instead of = you use - and instead of & you use /. Here’s the same example as above:
Example: listViewer.php/color-blue/size-XXL/
The quickest way to determine if your server supports “Path Info” searches is to try one. Servers that don’t support it will give a “not found” or other error message.
MySQL WHERE Searches (Advanced)
Section titled “MySQL WHERE Searches (Advanced)”If you are comfortable with MySQL you can specify a custom MySQL WHERE clause in the List Viewer options. Search conditions from the query string are combined with the where option. Records must match both: (where) AND (search).
Example: 'where' => 'price >= 250000 AND bedrooms = 2',