content_intersect

Given two JSON arrays of content items, returns only those items which exist in both arrays.

array content_intersect( array content1, array content2 )

The source arrays can be:

  • content objects from a Horizon content feed.
  • content objects from a custom content feed.
  • horizon_select item recommendations for the user.
  • Sailthru Prediction Manager item predictions for the user.

For example, you could use this function to return items that are in both your custom Popular Content feed and in the horizon_select array of user-specific item recommendations.

This function is also the exclusive method for surfacing Sailthru Prediction Manager item predictions in your templates. If you have implemented Sailthru Prediction Manager, the Zephyr function item_predictions returns an array of item IDs representing the items that the user is most likely to purchase. To return content objects matching those item IDs, use content_intersect on that array of IDs in conjunction with a Horizon content feed, a custom content feed, or the user’s horizon_select recommendations.

Examples

Return an array of items that are in your custom feed* and also match horizon_select recommendations for the user

content_intersect(horizon_select(), content)

*The “content” array uses whichever feed has been selected by your template, whether a Horizon content feed or a custom content feed.

Return an array of predictions matching the template’s current feed

content_intersect(item_predictions(50), content)

Return an array of predictions matching horizon_select recommendations for the user

content_intersect(item_predictions(50), horizon_select())
Top