{conds:text:mode}

Description

Formats a value (or a list of values) into a search condition you can drop into an {ids} or {view} query. Given a field id of the current item, it reads that fields values; given literal text or a JSON array such as ["sky","ice"], it uses those values directly. Multiple values are joined with OR so the condition matches any of them. The mode controls the output form: empty (the default) URL-encodes the value for a view.php query-string parameter; 1 double-quotes it for an {ids} d-FIELD-=-VALUE condition; == returns the bare value for the {ids} == operator. Because {ids} conditions use a single dash as the field-operator-value separator, every literal dash in a value is doubled (- becomes --) so the value is not mis-split. An empty value yields the sentinel AAnoCONDITION in quoted/encoded mode (so an empty filter matches nothing rather than everything) and an empty string in == mode.

Parameters

text required

A field id of the current item (its values are read and joined) OR a literal value (or a JSON array of values like ["sky","ice"]) to format. When it names a field of the current item, that fields values are used; otherwise the text is taken as the value(s).

mode optional default (empty - URL-encode)

How to format the output. Empty (default) URL-encodes the value for a view.php query parameter; 1 double-quotes it for an {ids:} d-FIELD-=-VALUE condition; == returns the bare value for the {ids:} == operator. Literal dashes in values are always doubled (- becomes --).

Examples

test[{conds:My Category:1}]
Expected["My Category"]
Actual["My Category"]
Mode 1 wraps the value in double quotes for use as the value side of an {ids:} d-FIELD-=-VALUE condition.
test[{conds:Sports:==}]
Expected[Sports]
Actual[Sports]
Mode == returns the value unquoted, for the {ids:} == (exact match) operator.
test[{conds:My Category}]
Expected[%22My%20Category%22]
Actual[%22My%20Category%22]
With no mode the value is URL-encoded (quotes to %22, spaces to %20) so it can be passed as a view.php query parameter.
test{conds:["sky","ice"]:1}
Expected"sky" OR "ice"
Actual"sky" OR "ice"
A JSON array of values becomes an OR-joined, quoted condition - one match for any of the listed values.
test{conds:["sky","ice"]:==}
Expectedsky OR ice
Actualsky OR ice
In == mode the OR-joined values are left unquoted.
test[{conds:["2024-03-15"]:1}]
Expected["2024--03--15"]
Actual["2024--03--15"]
Because {ids:} conditions use a single dash as the field-operator-value separator, {conds:} doubles every literal dash (- becomes --) so the value survives intact.
test[{conds::1}]
Expected[AAnoCONDITION]
Actual[AAnoCONDITION]
An empty value in mode 1 or default mode returns the sentinel AAnoCONDITION (matches nothing) so an empty filter does not accidentally match every item. In == mode an empty value returns nothing.
virtual{count:{ids:9e1d2b9f88e3d6c3bf0eb967378610d6:d-abstract........-==-{conds:_#SHORTTXT:==}}}
Expected(depends on data; e.g. 1)
Actual0
The everyday pattern: feed {conds:fieldalias:==} as the value of an {ids:} condition so the current items field value drives the filter. Output depends on the matching items at render time.