Documentation Center

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:

AttributeDescriptionValue
negateBoolean to switch the condition.See "negate attribute values" section.
nameThe field name, metadata field name, Keyword, or ID of a Content Manager item or metadata field.See "name attribute values" section.
operatorThe value indicates a filter to apply to items. Use the Any or All values to filter multi-value fields.See "operator attribute values" section.
multiValueBoolean to indicate that the attribute you want to filter on allows multiple values, as defined by the Schema. true or false

operator attribute values

The following table lists attributes values for the operator attribute:
operator ValueReturnsData types
equalsItems that match the value exactlytext, float
lessThanItems that are less than the value specifiedfloat
greaterThanOrEqualsItems that match the value exactly or are more than the value specifiedfloat
betweenItems that are in between the values specified (including lower value, excluding upper value)float
containsItems that contain the value specifiedcat (hierarchical field type)
anyItems where one of the attribute values matches (OR)list, set
anyExclusiveItems 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
allItems that match all attribute values (AND)set
allExclusiveItems that have only the values specified in the attribute values, and no otherslist, 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 name attribute:

name ValueDescriptionValueExample
componentnameThe name of a Component to filter on.StringExperience Optimization fact sheet
publicationidThe Item ID of the Publication to filter on.TCM URItcm:0-3-1
publicationtitleThe title of the Publication to filter on.StringEnglish Website
schemaidThe Item ID of the Schema to filter on.TCM URItcm:3-25-8
schematitleThe title of the Schema to filter on.StringProduct
secondidThe content item's second ID; the combination of the Component and Component Template TCM URIs.Escaped combined TCM URItcm_9-11-1104-16_tcm_9-919-32
templateidThe Item ID of the Component Template to filter on.TCM URItcm:3-67-32
templatetitleThe title of the Component Template to filter on.StringShortened Description
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 name attribute and value element to filter content:
TypeDescriptionName FormatExample of nameExample of value
<FieldName>The field to filter on.SchemaTCMURI_FieldNametcm_41_5603_8_surnameDe Groot
<MetadataFieldName>The metadata field to filter on.Metadata_SchemaTCMURI_FieldNamemetadata_tcm_41_5603_8_nameJason
<Keyword>The Keyword field to filter on.SchemaTCMURI_FieldName

or

Metadata_SchemaTCMURI_FieldName
tcm_41_5603_8_carsColortcm_5_101_1024

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>