{modulefield:slice_id:property}

Description

Reads a property of a slice (or any module) by its id. The first argument is the slice id; the second names the property. With no second argument, or any unrecognized name that does not begin with an underscore, it returns the module name. Recognized properties: url (the URL set in the module settings, empty when unset), charset (the slice character encoding, such as windows-1250 or utf-8), site_ids and site_id (the dash-separated ids of the sites that use the slice), and any slice setting field whose id begins with an underscore (empty when that field is unset). The value is returned as stored, not HTML-escaped - wrap it in safe when you put it into an HTML attribute. It is the modern replacement for the deprecated slice command and for the older alias slice_info syntax. Returns an empty string when the slice id is missing.

Parameters

slice_id required default (empty - returns an empty string)

The 32-character id of the slice (or of any other module - a site, a polls module) whose property you want. For the slice of the item being shown, pass the _#SLICE_ID alias wrapped in braces. Without an id the command returns an empty string. An id that names no module gives an empty string for name, url, site_ids and setting fields, but charset then returns the install default encoding (utf-8 on this install), so do not use charset to test whether an id exists.

property optional default (empty - the module name)

Which property to read: name (the module title), url (the URL set in the module settings), charset (the character encoding), site_ids (the ids of the sites that use the slice; site_id is an older spelling of the same), or the id of a slice setting field - a field whose id begins with an underscore. The names are case-sensitive. An empty value or any other text that does not begin with an underscore returns the name, so a typo silently gives you the name instead of an error. A mistyped or unset setting field id (one that begins with an underscore) returns an empty string instead.

Allowed values name (or empty) - the module title; url - the URL set in the module settings (for a slice its slice URL, for a site its site URL), empty when unset; charset - the character encoding, e.g. utf-8, given by the language file chosen in the slice settings; site_ids - the dash-separated ids of the site modules that list this slice among their used slices, deleted sites left out, empty when no site uses it (site_id is the older spelling); _<field id> - a slice setting field: a field with an id beginning with an underscore, whose value is edited in the slice settings rather than in items; only the first value is returned, and only slices have them

Examples

test{modulefield:9e1d2b9f88e3d6c3bf0eb967378610d6}
ExpectedAA Test Data - Stable
ActualAA Test Data - Stable
With only the slice id and no property, modulefield returns the slice name.
test{modulefield:{_#SLICE_ID}}
ExpectedAA Expressions Examples
ActualAA Expressions Examples
The usual form in a view or slice template: _#SLICE_ID in braces is the id of the slice the current item lives in. Here the current item is this example, which lives in the AA Expressions Examples slice.
test{modulefield:9e1d2b9f88e3d6c3bf0eb967378610d6:charset}
Expectedutf-8
Actualutf-8
The charset property returns the slice's character encoding (for example windows-1250 or utf-8).
test{modulefield:9e1d2b9f88e3d6c3bf0eb967378610d6:site_ids}
Expectede23064a57a7a468976ce0712eef44932
Actuale23064a57a7a468976ce0712eef44932
site_ids returns the dash-separated ids of the sites this slice belongs to. site_id is an older alias for the same value.
test{modulefield:{modulefield:9e1d2b9f88e3d6c3bf0eb967378610d6:site_ids}}
ExpectedActionApps - Examples and Tests - Data Site
ActualActionApps - Examples and Tests - Data Site
site_ids gives the site module id, and that id is again a module id, so a second modulefield reads the site name. Works as long as the slice belongs to exactly one site.
test[{modulefield:9e1d2b9f88e3d6c3bf0eb967378610d6:url}]
Expected[]
Actual[]
url returns the slice's configured URL. It is empty when no slice URL has been set, as on this fixture slice.
test{modulefield:e23064a57a7a468976ce0712eef44932:url}
Expectedhttps://actionapps.org/
Actualhttps://actionapps.org/
url works for any module. Here it reads the site that the Stable test slice belongs to; a slice gives its slice URL setting the same way.
virtual{modulefield:2dddbc992c0f88b06d81cec788e8fd39:_category.......}
Expected(the value of that setting field - blue on this install)
Actualblue
A property that begins with an underscore reads a slice setting field. The Central Test - Articles slice on this install has the setting field _category....... set to blue; slices without such a field return an empty string.
test{modulefield:9e1d2b9f88e3d6c3bf0eb967378610d6:}
ExpectedAA Test Data - Stable
ActualAA Test Data - Stable
An empty second argument is treated the same as no argument and returns the slice name.
test{modulefield:9e1d2b9f88e3d6c3bf0eb967378610d6:nonsense}
ExpectedAA Test Data - Stable
ActualAA Test Data - Stable
A property that is not recognized and does not begin with an underscore falls back to the slice name rather than failing. Use only the documented property names.
test[{modulefield:}]
Expected[]
Actual[]
With no slice id, modulefield returns an empty string. The square brackets in this example are literal, to make the empty result visible.
virtual{site:{modulefield:9e1d2b9f88e3d6c3bf0eb967378610d6:site_ids}:modules}
Expected(dash-separated ids of all slices in the site, e.g. 9eb077b2...-15deb349...-2f3fef5b...)
Actual34c910af6b659bbc2bfef48204c89772-9eb077b2fd21d909d3b11f54f3c55e1b-2bdaf58a9b222e5bb219f83483898a4f-15deb349ab0e1a90329f1635b9502be6-2f3fef5ba522680d1dd5f681a814bf84-402caacffa2f9ae22b81b597b3264186-9e1d2b9f88e3d6c3bf0eb967378610d6-133d91fa4fe87a808ed721a5efaf2016
The real-world use is nesting modulefield inside another command. Here site_ids is fed to the site command to list every slice in the slice's site (dash-separated ids). The core engine uses this exact pattern when it computes seo names. Marked illustrative because the result depends on which slices currently share the site.