{seo2ids:slices:seo_string:bins}

Description

Looks up items by their SEO slug and returns their long ids. It searches the given slices for items whose seo............. field exactly equals the seo_string you pass, and returns the matching long ids joined by dashes (normally just one). This is the reverse of seoname, which builds a slug, and it is the mechanism behind friendly URLs: the site router takes a path like /expressions/seo2ids and uses seo2ids to find the item that page should show. Only slices that actually have a seo............. field are searched; others are skipped silently. An empty seo_string returns nothing. By default it looks in the approved bins (active, pending and expired); pass the bins argument to widen or narrow that. Feed the resulting id straight into item, view or count to read or render the matched item.

Parameters

slices optional default (empty) - slices of the current context

Dash-separated list of slice ids to search. Only slices that actually have a seo............. field are searched; ids of slices without one are quietly skipped. Leave it empty (or pass all) to search the slices related to the current item, site or slice context, which is how site navigation templates resolve a path within the current site.

seo_string required default (none - required)

The exact SEO string to match against each item's seo............. field. The match is exact, not a prefix or substring. An empty string makes the command return nothing immediately. Dashes in the string are fine - they are part of the slug, not a separator here.

bins optional default (empty) = 7 (active+pending+expired)

Which bins to search, as a numeric bitmask (active 1, pending 2, expired 4, holding 8, trash 16; add them to combine). When omitted it defaults to 7 = active plus pending plus expired (the approved item). Pass 255 to include every bin, holding and trash included - this is what seoname uses when it checks a slug for uniqueness.

Examples

test{seo2ids:15deb349ab0e1a90329f1635b9502be6:seo2ids}
Expected7b8598979121f52a90a58cae7ab40c24
Actual7b8598979121f52a90a58cae7ab40c24
Find the item in the given slice whose seo............. field equals seo2ids and return its long id. This is exactly how the friendly URL /expressions/seo2ids is turned back into the item the page should show.
test[{seo2ids:15deb349ab0e1a90329f1635b9502be6:no-such-slug-xyz}]
Expected[]
Actual[]
When no item in the searched slices carries that seo string, the result is the empty string (shown here inside brackets as []). Wrap the call in ifempty or test it with ifin before you use the id.
test[{seo2ids:15deb349ab0e1a90329f1635b9502be6:}]
Expected[]
Actual[]
An empty seo_string short-circuits to the empty string (shown here as [] inside brackets), no query is run. Useful when the slug comes from a variable that might be blank.
test[{seo2ids:9e1d2b9f88e3d6c3bf0eb967378610d6:seo2ids}]
Expected[]
Actual[]
seo2ids only searches slices that actually have a seo............. field. The test data slice has none, so even a valid-looking string matches nothing and the result is empty (shown as [] inside brackets). Slices without the field are skipped silently rather than raising an error.
test{seo2ids:15deb349ab0e1a90329f1635b9502be6-9e1d2b9f88e3d6c3bf0eb967378610d6:seo2ids}
Expected7b8598979121f52a90a58cae7ab40c24
Actual7b8598979121f52a90a58cae7ab40c24
Pass several slice ids joined by dashes to search them together. Here only the first slice has a seo............. field and an item with that slug, so its id comes back; the second slice contributes nothing.
test{count:{seo2ids:15deb349ab0e1a90329f1635b9502be6:seo2ids}}
Expected1
Actual1
seo2ids returns a dash-separated id list, so count tells you how many items hold that slug. One is the healthy case; zero means the slug is free; more than one means a duplicate slug you should fix.
test{item:{seo2ids:15deb349ab0e1a90329f1635b9502be6:seo2ids}:_#HEADLINE}
Expected{seo2ids:slices:seo_string:bins}
Actual{seo2ids:slices:seo_string:bins}
The common real-world pattern: feed the resolved id straight into item to print one of its fields. Here it returns the headline of the item whose slug is seo2ids.
virtual{item:{seo2ids::poradna}:_#SUBPATH_}
Expected(the matched item's _SUBPATH_ in the current site, or empty if none)
Leaving the slices argument empty searches the slices of the current site or item context. This is the production navigation pattern: take a URL slug like poradna and look up the matching item without naming a slice. The output depends on which site is rendering, so this example is illustrative.