Snippet
YAMS Snippet Call
The YAMS snippet call is used for obtaining and outputting multilingual content stored in document variables, template variables, chunks, snippets or whatever in the correct language. It is also used for repeating content in multiple languages based on templates.
By selecting the list, select or selectform options the same approach is used together with a default (but overridable) set of templates to create a hyperlinked list of language versions or a drop down select box of languages to enable switching the current language.
The YAMS snippet is in fact a macro for creating special hidden language constructs that are embedded in the document template and removed before the document is served. See the YAMS Technical Details page. These allow all possible language versions of the content to be embedded in a single document.
The blocks are reorganised and optimised as much as possible before a document is cached. This helps to ensure that as little parsing as possible is required to select the correct language content once it has been retrieved from the cache.
Note that language selection occurs after a document is retrieved from the cache, so it is not possible to end up caching the wrong language content. It is important that the YAMS snippet is run as a cacheable at all times, since this will allow pre-cache optimisation to be undertaken.
See the How To ? page tab for examples of its use.
YAMS Snippet Parameters
Parameter | Values | Description |
---|---|---|
&get |
|
These parameters choose from multiple language versions of a Use the |
text | In this case, the [!YAMS? &get=`text` &from=`de::german stuff||en::english stuff`!] |
|
data | This parameter is used to extract multilingual content from the document or template variables of specific documents. In this case, the &from parameter specifies the the names of the document or template variables from which the content will be extracted and This is primarily for use in the templates of snippets which don't understand multilingual variables. See the YAMS "How To" for more information. This parameter used to be called content. The content syntax still works, but is depracated and may be removed in a future version. So, please switch to using data.* |
|
repeat | Repeats multiple language versions of content on a page. This option works using the templates specified by the "&beforetpl", "&repeattpl", "¤ttpl" and "&aftertpl" parameters. If a "¤ttpl" template is specified, then it is used in place of "&repeattpl" for the current document language. Otherwise, the "&repeattpl" template is repeated for all languages. |
|
list | This functions in the same way as These default templates can be overridden using the "&beforetpl", "&repeattpl", "¤ttpl" and "&aftertpl" parameters. |
|
selectform | This functions in the same way as These default templates can be overridden using the "&beforetpl", "&repeattpl", "¤ttpl" and "&aftertpl" parameters. |
|
select | This functions in the same way as &get=`selectform` except that it only outputs the select box, not the form. |
|
&from | resource_name | This parameter enables the names of the chunks/snippets etc. in which the information lies to be specified. It has two forms: In the first, simpler form, the basename of a resource, say, resource_name is specified. On multilingual pages this will be replaced by a construct that includes one language variant for each active language group. The language variants are assumed to have the name resource_name_id, where id is the language group id. These language variants are subject to normal Evo caching. When a request is made for the document in a given language, all incorrect language variants are stripped out, allowing the user to see only the correct language content. |
id1::resource_name1||id2::resource_name1||… |
In the second, more complex form, the languages group ids and full resource names for each language are specified. Here id1, id2, …, are the language group ids, and resource_name1, … are the full corresponding resource names. When using |
|
&docid | A document identifier | The document identifier of the document from which to obtain the data. This is for use with the &get=`data` parameter. |
&beforetpl | a chunk name@CODE :template code@FILE :path to template file |
Specifies a template to be placed before a repeat block. |
&repeattpl | a chunk name@CODE :template code@FILE :path to template file |
Specifies a template to be repeated once for each active language. Can be overridden by the "¤ttpl" param. |
¤ttpl | a chunk name@CODE :template code@FILE :path to template file |
Specifies a template to be used if it is in the same language as the current document. Overrides by the "&repeattpl". |
&aftertpl | a chunk name@CODE :template code@FILE :path to template file |
Specifies a template to be placed after a repeat block. |
Suggest an edit to this page.