In the content editor, it's possible to apply a filter to a Smarty variable with a list of data. This can involve an exact match or a comparison using a wildcard.

filter

{{$object|filter:'<Field_name>':'<Value>'}} 
{{$object|filter:'<Field_name>':'<Condition>':'<Value>'}} 

Examples

Using a `foreach` loop, the contents of the variable can be displayed:

Filter the list of products with the product ID 30.

<!--{foreach $lookup.products|filter:"id":"30" as $article}→
  <li>Brand: {{$article.brand}}</li>
  <li>Description: {{$article.description}}</li>
  <li>Condition: {{$article.condition}}</li>
  <li>Material: {{$article.material}}</li>
  <li>Link: {{$article.link}}</li>
  <li>Image: {{$article.image_link}}</li>
<!--{foreachelse}-->
   Default variation when no data is found.
<!--{/foreach}-->

Filter products which contain a certain value

{{* Retrieve all products where the product ID contains the value 30. *}} 
<!--{foreach $lookup.products|filter:"id":"contains":"30" as $article}-->
  <li>Brand: {{$article.brand}}</li>
  <li>Description: {{$article.description}}</li>
  <li>Condition: {{$article.condition}}</li>
  <li>Material: {{$article.material}}</li>
  <li>Link: {{$article.link}}</li>
  <li>Image: {{$article.image_link}}</li>
<!--{foreachelse}-->
   Default variation when no data is found.
<!--{/foreach}-->


{{* Retrieve all products where the product ID contains the value 30 with wildcards *}}
<!--{foreach $lookup.products|filter:"id":"*30*" as $article}-->
  <li>Brand: {{$article.brand}}</li>
  <li>Description: {{$article.description}}</li>
  <li>Condition: {{$article.condition}}</li>
  <li>Material: {{$article.material}}</li>
  <li>Link: {{$article.link}}</li>
  <li>Image: {{$article.image_link}}</li>
<!--{foreachelse}-->
   Default variation when no data is found.
<!--{/foreach}-->


{{* Retrieve all products where the product ID starts with 601 *}}
<!--{foreach $lookup.products|filter:"id":"601*" as $article}-->
  <li>Brand: {{$article.brand}}</li>
  <li>Description: {{$article.description}}</li>
  <li>Condition: {{$article.condition}}</li>
  <li>Material: {{$article.material}}</li>
  <li>Link: {{$article.link}}</li>
  <li>Image: {{$article.image_link}}</li>
<!--{foreachelse}-->
   Default variation when no data is found.
<!--{/foreach}-->

The following example retrieves all products using the creation date with the `date_format` modifier:

Filter the product values based on a date

See our latest products:

<!--{foreach $lookup.products|filter:"createdat":"{{$smarty.now|date_format:'%Y-%m-%d'}}" as $article}-->
  <li>Brand: {{$article.brand}}</li>
  <li>Description: {{$article.description}}</li>
  <li>Condition: {{$article.condition}}</li>
  <li>Material: {{$article.material}}</li>
  <li>Link: {{$article.link}}</li>
  <li>Image: {{$article.image_link}}</li>
<!--{foreachelse}-->
  Default variation when no data is found.
<!--{/foreach}-->