tcdl:attribute
The <tcdl:attribute> tag defines a name and value pair that is added to a OpenSearch query to filter a result set on attributes. You can use the <tcdl:attribute> tag to filterPromotions, items returned by Promotions, and Items returned by a search query.
Syntax (AND operations)
You can filter content items using several <tcdl:attribute> tags, which are then treated as AND operations. In the following example, the content is filtered on Component Presentations that use Schema tcm:5-808-8 and Component Template tcm:5-1002-32:
<tcdl:attribute name="schemaid">
<tcdl:value>tcm:5-808-8</tcdl:value>
</tcdl:attribute>
<tcdl:attribute name="templateid">
<tcdl:value>tcm:5-1002-32</tcdl:value>
</tcdl:attribute>
Syntax (OR operations)
You can create OR operations by adding multiple values as subelements within the <tcdl:attribute>. You can only use OR operations for attributes in OpenSearch that are of basetype list or set:
<tcdl:attribute name="templateid">
<tcdl:value>tcm:5-1001-32</tcdl:value>
<tcdl:value>tcm:5-1002-32</tcdl:value>
</tcdl:attribute>
Attributes
The <tcdl:attribute> tag has the following attributes:
| Attribute | Description | Value |
|---|---|---|
negate | Boolean to switch the condition. | See "negate attribute values" section. |
name | The field name, metadata field name, Keyword, or ID of a Content Manager item or metadata field. | See "name attribute values" section. |
operator | The value indicates a filter to apply to items. Use the Any or All values to filter multi-value fields. | See "operator attribute values" section. |
multiValue | Boolean to indicate that the attribute you want to filter on allows multiple values, as defined by the Schema.
| true or false |
operator attribute values
operator attribute:
operator Value | Returns | Data types |
|---|---|---|
equals | Items that match the value exactly | text, float |
lessThan | Items that are less than the value specified | float |
greaterThanOrEquals | Items that match the value exactly or are more than the value specified | float |
between | Items that are in between the values specified (including lower value, excluding upper value) | float |
contains | Items that contain the value specified | cat (hierarchical field type) |
any | Items where one of the attribute values matches (OR) | list, set |
anyExclusive | Items where one of the attribute values matches (OR), and no others. Items that have no value are also matched (to exclude these, define additional filters). | list, set |
all | Items that match all attribute values (AND) | set |
allExclusive | Items that have only the values specified in the attribute values, and no others | list, set |
-
Example:
greaterThanOrEquals -
<tcdl:attribute name="SchemaTCMURI_Age" operator="greaterThanOrEquals" value="18" /> -
Example:
between -
<tcdl:attribute name="SchemaTCMURI_Age" operator="between"> <tcdl:value>18</tcdl:value> <tcdl:value>30</tcdl:value> </tcdl:attribute>
name attribute values
- Standard values
-
The following table lists standard attributes for Content Manager items in OpenSearch that you can use for the
nameattribute: - Values based on Component fields
-
The following table lists attributes in OpenSearch derived from Component fields in Content Manager. The table indicates the format you need to use in the
nameattribute andvalueelement to filter content:
negate attribute
In the following example, the result set is filtered on Promotions or items that are NOT red:
<tcdl:attribute negate="true" name="tcm_41_5553_8_color">
<tcdl:value>red</tcdl:value>
</tcdl:attribute>