Skip to content

Search

CMS Builder makes it easy to develop custom search engines quickly.

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.

FormatSearch TypeNotes
fieldnameExact matchEntire field value must match (case-insensitive). For multi-value list fields only one of the field values must match.
fieldname_matchExact matchSame as above.
fieldname_keywordContains keywordField value must contain the keyword (case-insensitive).
fieldname_prefixStarts withField value must start with the keyword (or letter).
fieldname_queryMatches queryAllows 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_emptyMatches blank fieldsMatches fields that are blank (""). Example: email_empty=1
fieldname_minMinimum valueFor numeric searches (can also be used for date searches if the date is specified as YYYYMMDDHHMMSS; non-numeric chars are ignored).
fieldname_maxMaximum valueFor numeric searches (can also be used for date searches if the date is specified as YYYYMMDDHHMMSS; non-numeric chars are ignored).
fieldname_yearYear numberFor date searches.
fieldname_monthMonth numberFor date searches.
fieldname_dayDay of monthFor date searches.
fieldname_match[]Multi value OR searchTo 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 createdDate and updatedDate fields support date searches (_min, _max, _year, _month, _day) even though they aren’t regular date fields.
  • For _min/_max searches on date fields, an 8-digit YYYYMMDD value is expanded to cover the whole day: date_min=20250101 matches from the start of January 1st and date_max=20250101 matches to the end of it.

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

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

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

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.

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>

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.

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',

Documents CMS Builder 3.83