tcdl:attribute
The <tcdl:attribute> tag defines a name and value pair that is added to a Fredhoppper 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 Fredhopper 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 below |
name | The field name, metadata field name, Keyword, or ID of a Content Manager item or metadata field. | See below |
operator | The value indicates a filter to apply to items. Use the Any or All values to filter multi-value fields. | See below |
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 | Applicable basetypes |
|---|---|---|
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 basetype) |
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 standard values
The following table lists standard attributes for Content Manager items in Fredhopper that you can use for the name attribute:
name Value | Description | Value | Example |
|---|---|---|---|
| componentname | The name of a Component to filter on. | String | SmartTarget fact sheet |
| publicationid | The Item ID of the Publication to filter on. | TCM URI | tcm:0-3-1 |
| publicationtitle | The title of the Publication to filter on. | String | English Web site |
| schemaid | The Item ID of the Schema to filter on. | TCM URI | tcm:3-25-8 |
| schematitle | The title of the Schema to filter on. | String | Product |
| secondid | The content item's secondid; the combination of the Component and Component Template TCM URIs. | Escaped combined TCM URI | tcm_9-11-1104-16_tcm_9-919-32 |
| templateid | The Item ID of the Component Template to filter on. | TCM URI | tcm:3-67-32 |
| templatetitle | The title of the Component Template to filter on. | String | ShortenedDescription |
name attribute values based on Component fields
The following table lists attributes in Fredhopper 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:
| Type | Description | Name Format | Example of name | Example of value |
|---|---|---|---|---|
| <FieldName> | The field to filter on. | SchemaTCMURI_FieldName | tcm_41_5603_8_surname | De Groot |
| <MetadataFieldName> | The metadata field to filter on. | Metadata_SchemaTCMURI_FieldName | metadata_tcm_41_5603_8_name | Jason |
| <Keyword> | The Keyword field to filter on. | SchemaTCMURI_FieldName or Metadata_SchemaTCMURI_FieldName | tcm_41_5603_8_carsColor | tcm_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>