Dynamic View: Show Items with the Same Tag or Nothing
This solution shows configuring a filter in the field “Dynamic View” based on a tagbox. The field dynamic view will show related content based on an assigned tag e.g. tag = project X, related content = all content that also is tagged with project X.
This solution shows how to show related projects. Without any project assigned don’t show the dynamic view field (if no related projects are possible, as no project is tagged).
Instructions
You add the Dynamic View field
You want to have two filters
Show related projects
CODE{ "kind": "TermFilter", "field": "projects.newProject._refId", "term": "{{data.projects.newProject[0]._refId}}" }
Show nothing if there is no value in the tagbox for projects
CODE{ "kind": "ExistsFilter", "field": "projects.newProject._refId" }
For the dynamic view - both filters must be true hence you need an AND filter
JSON{ "kind": "AndFilter", "filters": [ { "kind": "ExistsFilter", "field": "projects.newProject._refId" }, { "kind": "TermFilter", "field": "projects.newProject._refId", "term": "{{data.projects.newProject._refId}}" } ] }
This filter will show all related projects, and at least one project must exist on the Content Item.
For multi tagboxes, you must include the Nested Filter
CODE{ "kind": "NestedFilter", "path": "projects.newProject", "filter": { "kind": "AndFilter", "filters": [ { "kind": "ExistsFilter", "field": "projects.newProject._refId" }, { "kind": "TermFilter", "field": "projects.newProject._refId", "term": "{{data.projects.newProject[0]._refId}}" } ] } }
For multi tagbox, you must include an index value for the term in the term filter e.g.
aa) match the 1st tag: "term": "{{data.projects.newProject[0]._refId}}"
ab) match the 2nd tag: "term": "{{data.projects.newProject[1]._refId}}"
ac) match 1st and 2nd tag: change to TermsFilter and
"terms":["{{data.projects.newProject[0]._refId}}", "{{data.projects.newProject[1]._refId}}"]
This filter will always include the original content item (the base). If you want to remove the original, you exclude the id from the dynamic view - you can just add this to the AND filter:
- JSON
{ "kind": "NotFilter", "filter": { "kind": "TermFilter", "field": "id", "term": "{{id}}" } }