All add-ons

Low Search

Just $79.00 per license

Compatibility: EE2, EE3
Latest release: 5.1.0 (released 2017-03-23)
Licensing: Commercial License Agreement

Helper functions

There are several helper functions and methods that will help you create your own filters. They are located in several files and objects.

Low_search_filter

The parent class is located in /low_search/filter.low_search.php. Use $this->method_name() in your filter class.

_get_field_id

Deprecated since v4.2.0. Use $this->fields->id() instead.

Deprecated since v4.2.0. Use $this->fields->sql() instead.

_remove_rogue_vars

Removes unset variables from the template before EE does it. Useful if your vars could be input for other tags.

Arguments

  • $key (string or array) — the variable name or names you wish to remove.
  • $prefix (bool, optional) — whether to apply the low_search_ prefix to the given names. Defaults to TRUE.

_log

A shortcut for ee()->TMPL->log_item().

Arguments

  • $msg (string) — the message you wish to log.

Low_search_params

The library class is located in /low_search/libraries/Low_search_params.php and mapped to $this->params. Use $this->params->method_name() in your filter class.

explode

Turns a multi-valued parameter string to an array.

Arguments

  • $str (string) — parameter to explode.

Returns

An array where the first value contains the exploded values and the second value is a boolean whether the parameter had not  prefixed to it.

get

Gets all parameters for this search query, or a single one.

Arguments

  • $key (string, optional) — parameter name to get. Omit for all.
  • $fallback (mixed, optional) — value to return if parameter is not set.

Returns

All parameters if no key is given, the parameter value if present, or the fallback if not present.

get_prefixed

Gets all parameters where the name starts with given string.

Arguments

  • $prefix (string) — prefix to look for.
  • $strip (bool) — whether to strip the prefix from the parameter name when returning the matching parameters.

Returns

An associative array of the matching parameters.

in_param

Checks if given value is present in given parameter.

Arguments

  • $val (string) — value to look for.
  • $param (string) — the parameter name which may or may not contain that value.

Returns

Bool

prep

Modifies a parameter value to EE syntax based on the presence of the parameter name in other parameters like require_all or exclude.

Arguments

  • $key (string) — parameter name.
  • $val (string) — parameter value.

Returns

The modified value.

site_ids

Gets the current site IDs based on the site parameter.

Returns

An array of the current site IDs.

Low_search_fields

The library class is located in /low_search/libraries/Low_search_fields.php and mapped to $this->fields. Use $this->fields->method_name() in your filter class.

id

Retrieves the field ID for the given custom field name.

Arguments

  • $name (string) — the field name.

Returns

The field ID found, or 0 if no valid ID is found.

is_native

Determines whether given field name is native, ie. part of the exp_channel_titles table.

Arguments

  • $name (string) — the field name.

Returns

TRUE or FALSE.

is_date

Determines whether given field name is a date field, custom or native.

Arguments

  • $name (string) — the field name.

Returns

TRUE or FALSE.

is_grid

Determines whether given field name is a Grid field.

Arguments

  • $name (string) — the field name.

Returns

TRUE or FALSE.

is_rel

Determines whether given field name is a Relationships field.

Arguments

  • $name (string) — the field name.

Returns

TRUE or FALSE.

is_third_party_field_name

Determines whether given field name is a third_party_field_name field, where that field uses var pair syntax. For example: is_matrix or is_playa.

Arguments

  • $name (string) — the field name.

Returns

TRUE or FALSE.

grid_col_id

Retrieves the Grid column ID for the given grid column name.

Arguments

  • $field_id (int) — the Grid field ID.
  • $name (string) — the column name.

Returns

The field ID found, or FALSE if no valid ID is found.

sql

Returns a SQL where-clause based on given table column name and parameter value, using the Field Search syntax rules.

Arguments

  • $col (string) — the database table column name, eg. field_id_5
  • $val (string) — a parameter value, eg. =foo|bar

Returns

A SQL where-clause, eg. ((field_id_5 = 'foo') OR (field_id_5 = 'bar'))

Low_search_settings

The library class is located in /low_search/libraries/Low_search_settings.php. Use ee()->low_search_settings->method_name() in your filter class.

get

Gets all settings, or a single one.

Arguments

  • $key (string, optional) — setting name to get. Omit for all.
  • $fallback (mixed, optional) — value to return if setting is not set.

Returns

All settings if no key is given, the setting value if present, or the fallback if not present.

Low Search Helper

The helper file is located in /low_search/helpers/low_search_helper.php. Use function_name() in your filter class.

low_array_is_numeric

Checks if given array only consists of numeric values.

Arguments

  • $array (array) — array to check.

Returns

Bool

low_flatten_results

See: array_column. Also works for PHP < 5.5.