{intersect:set1:set2}

Description

Returns the set intersection of two dash-separated id lists: the ids found in both set1 and set2, dash-separated. Output keeps the order of set1 and drops empty entries; duplicate ids inside set1 are preserved. Built on array_intersect over explode_ids, so each side is split on dashes and trimmed. A common use is to keep only the items a query or view returned that are also in some allowed or selected list. The companion command removeids returns set1 with the ids of set2 taken out.

Parameters

set1 required default (empty)

First dash-separated id list. The output keeps the order of this set, and an id from here is included only if it also appears in set2. Empty entries are dropped; duplicate ids are kept.

set2 required default (empty)

Second dash-separated id list. It acts as the filter: only ids that also occur in this set survive. Order and duplicates here do not affect the result.

Examples

test{intersect:1-2-3:2-3-4}
Expected2-3
Actual2-3
The result holds the ids present in both lists. 1 is only in the first list and 4 only in the second, so both are dropped.
test{intersect:7-7-9--12:7-12}
Expected7-7-12
Actual7-7-12
set1 is split on dashes and trimmed, so the empty piece between the double dash is dropped, but a repeated id (7-7) is preserved. 9 is not in the second list, so only 7-7-12 remain.
test{intersect:11-12-13-14-15:12-15-99}
Expected12-15
Actual12-15
The real-world pattern: the first list is what a query or view returned, the second is an allow-list. Wrapping a query in intersect, as in {intersect:{ids:SLICE:CONDITION}:12-15-99}, keeps only the returned ids that are also allowed. 99 is allowed but was not returned, so it does not appear.
test[{intersect:1-2:3-4}]
Expected[]
Actual[]
When the two lists share nothing, intersect returns the empty string. The square brackets are literal text added so the empty output is visible as [].
test{intersect:5-3-1:1-3-5}
Expected5-3-1
Actual5-3-1
Both lists hold the same ids but in different order. The output is ordered by set1 (the first list), not set2.
test{intersect:apple-pear-plum:plum-apple}
Expectedapple-plum
Actualapple-plum
The values do not have to be numeric ids; any dash-separated tokens work. pear is missing from the second list and is dropped.