Documentation for the Freemarker functions provided by ccm-themedirector

git-svn-id: https://svn.libreccm.org/ccm/trunk@6130 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2019-06-10 17:47:47 +00:00
parent c1e55fa675
commit b7f454275a
2 changed files with 30 additions and 36 deletions

View File

@ -0,0 +1,23 @@
# Freemarker functions for language related tasks.
Import Path
:`/ccm-themedirector/language.ftl`
### `getAvailableLanguages(): Sequence<String> `
Returns the available languages for the current document as sequence. This
sequence can be used for creating links for selecting the language:
<ul class="language-selector">
<#list Lang.getAvailableLanguages()?sort as lang>
<li class="${(lang==negotiatedLanguage)?then('selected', '')}">${lang}</li>
</#list>
</ul>
This example uses the `list` directive from Freemarker to iterate over
the available languages returned by `getAvailableLanguages` The
Freemarker build-in `?then` is used together with the
`negotiatedLanguage` variable to check if the curent language is the
selected language. If this is the case a CSS class is added to the
HTML.

View File

@ -1,48 +1,23 @@
# Freemarker functions provided by ccm-themedirector # Utility functions
## Language utilities
Provides functions for gettign the available languages for the current page.
Import Path
:`/ccm-themedirector/language.ftl`
### `getAvailableLanguages(): Sequence<String> `
Returns the available languages for the current document as sequence. This
sequence can be used for creating links for selecting the language:
<ul class="language-selector">
<#list Lang.getAvailableLanguages()?sort as lang>
<li class="${(lang==negotiatedLanguage)?then('selected', '')}">${lang}</li>
</#list>
</ul>
This example uses the `list` directive from Freemarker to iterate over the available languages returned by `getAvailableLanguages` The Freemarker build-in `?then` is used together with the `negotiatedLanguage` variable to
check if the curent language is the selected language. If this is the case
a CSS class is added to the HTML.
## Utility functions
Import Path Import Path
:`/ccm-themedirectory/utils.ftl` :`/ccm-themedirectory/utils.ftl`
### `String getPageApplication()` ## `getPageApplication(): String`
Return the application of the current page. Return the application of the current page.
### `String getPageTitle()` ## `getPageTitle(): String`
Return the title of the current page as provided by the Return the title of the current page as provided by the
_Category Menu_ Component of the _ccm-navigation_ module. _Category Menu_ Component of the _ccm-navigation_ module.
### `String getSiteHostName()` ## `getSiteHostName(): String`
Returns the host name of the CCM installation as provided by the Returns the host name of the CCM installation as provided by the
_SiteBanner_ component of the _ccm-core_ module. _SiteBanner_ component of the _ccm-core_ module.
### `String getSiteName()` ## `getSiteName(): String`
Returns the host name of the CCM installation as provided by the Returns the host name of the CCM installation as provided by the
_SiteBanner_ component of the _ccm-core_ module. _SiteBanner_ component of the _ccm-core_ module.
@ -61,9 +36,7 @@ section. It is possible to define different styles for different languages.
The style definition in the theme manifest must be in the format expected by the Java The style definition in the theme manifest must be in the format expected by the Java
[DateTimeFormatter](https://docs.oracle.com/javase/8/docs/api/index.html?java/time/format/DateTimeFormatter.html) class. [DateTimeFormatter](https://docs.oracle.com/javase/8/docs/api/index.html?java/time/format/DateTimeFormatter.html) class.
### Example
#### Example
In the theme manifest in the following format is defined: In the theme manifest in the following format is defined:
@ -102,6 +75,4 @@ In this example the `getNewsDate` function was used to retrieve the date of a ne
and for english: and for english:
4/1/19 4/1/19