{ifintersect:set1:set2:text:else_text}

Description

Tests whether two dash-separated sets of values share at least one member. set1 and set2 are split on dashes (members are trimmed; empty members are dropped). If the two sets have any common member, ifintersect returns text; otherwise it returns else_text. This is the set-overlap counterpart to ifset and ifeq, equivalent to checking that intersect of the two sets is non-empty. You may chain extra set2:text pairs after the first; the first set2 that overlaps set1 wins (the rest are skipped), and the trailing unpaired argument is the else_text fallback. Inside the returned text, _#1 expands to set1 and _#2 to the matching set2. Typical use is permission and tag matching: compare a content item rights set against the current user roles. ifintersect is never cached, so it re-evaluates on every render.

Parameters

set1 required

The first set, written as dash-separated members (for example editor-author-admin). Members are trimmed and empty ones are dropped. Often a content rights or tag set such as a field getter like {category........}. The order of set1 does not affect the test.

set2 required

The second set to test against set1, also dash-separated. ifintersect returns text when set1 and set2 have at least one member in common. A single value (no dashes) is a one-member set. You may add further set2:text pairs after this one; the first set2 that overlaps set1 wins.

text required

What to return when set1 and set2 overlap. Inside it, _#1 expands to set1 and _#2 to the matching set2, so you can echo the values without repeating them.

else_text optional default (empty string)

What to return when no set2 overlaps set1. Optional - if omitted, a non-overlapping test yields an empty string. As the trailing unpaired argument it is also the final fallback when chaining several set2:text pairs.

Examples

test{ifintersect:de-en:fr:French:en:English:Other}
ExpectedEnglish
ActualEnglish
You can chain pairs. set1 (de-en) does not overlap fr but does overlap en, so the second pair wins and Other is the trailing else_text fallback.
test[{ifintersect:a-b-c:x-y:only when shared}]
Expected[]
Actual[]
With no else_text and no overlap, ifintersect returns an empty string (shown here between literal brackets).
test{ifintersect:a-b::present:absent}
Expectedabsent
Actualabsent
An empty set2 (the double colon) has no members, so it can never overlap set1; else_text is returned.
test{ifintersect:editor-author-admin:admin:Access granted:Access denied}
ExpectedAccess granted
ActualAccess granted
The canonical use: set1 is a content rights set, set2 is the required role. admin is present, so access is granted. set2 here is a single-member set (no dashes).
test{ifintersect:editor-author:reviewer:Access granted:Access denied}
ExpectedAccess denied
ActualAccess denied
Same shape as the previous example, but reviewer is not among the rights, so else_text is returned.
test{ifintersect:red-green-blue:green-pink:matched _#2:no match}
Expectedmatched green-pink
Actualmatched green-pink
Inside text, _#2 expands to the matching set2 (green-pink). _#1 would expand to set1.
test{ifintersect:a-b-c:x-y-z:shared:none}
Expectednone
Actualnone
No member is common to both sets, so ifintersect returns else_text.
test{ifintersect:a-b-c:c-d-e:shared:none}
Expectedshared
Actualshared
set1 (a-b-c) and set2 (c-d-e) share the member c, so ifintersect returns text.