HTTL ηCMS extensions

HTTL basics

ηCMS provides additional HTTL utility methods. These extra methods allow using of services and ηCMS features on site pages. Methods are defined in two java classes: com.softmotions.ncms.mhttl.HttlAsmMethods and com.softmotions.ncms.mhttl.HttlUtilsMethods. You may explore their code as you deem necessary.

com.softmotions.ncms.mhttl .HttlAsmMethods

Methods designed to access ηCMS objects.

page()

Returns the object corresponding to the current assembly (page).

Example: obtaining the current page name(title):

${page().hname}
Return type:com.softmotions.ncms.asm.Asm
asmHasAttribute(String name)

Returns true if the current assembly has the attribute called name, which can be used in the httl markup.

Example:

#if(asmHasAttribute("title"))
    ${"title".asm}
#end
asmAny(String name)
asmAny(Asm asm, String name)

Returns a rendered value of the assembly attribute. The null will be returned if the attribute is not found.

Example:

${asmAny("title")}
Arguments:
  • asm (com.softmotions.ncms.asm.Asm) – Assembly, for which a named attribute will be searched
Return type:

java.lang.Object

asm(String name)
asm(Asm asm, String name)

Returns rendered attribute value for the current assembly.

Arguments:
  • name (String) – Attribute name. The parameter can include additional options of the attribute rendering. For example: ${asm(“title,option=value”)}.
  • asm (com.softmotions.ncms.asm.Asm) – Assembly for that a named attribute will be searched
Return type:

java.lang.Object

Below are alternative forms of obtaining attribute values with some display options:

asm(String name, String optionName, String optionValue)
asm(String name, String optionName, String optionValue, String optionName2, String optionValue2)
asm(String name, String optionName, String optionValue, String optionName2, String optionValue2, String optionName3, String optionValue3)
asm(Asm asm, String name, String optionName, String optionValue)
asm(Asm asm, String name, String optionName, String optionValue, String optionName2, String optionValue2)
asm(Asm asm, String name, String optionName, String optionValue, String optionName2, String optionValue2, String optionName3, String optionValue3)

Returns the rendered value of the attribute of the current assembly. Contains additional options rendering attribute value.

Returns URL to the page identified by the assembly

Return type:java.lang.String
link(String guidOrAlias)

Returns URL of the link to the page identified by string GUID page or page alias

Return type:java.lang.String
link(RichRef ref)

Returns URL for the object com.softmotions.ncms.mhttl.RichRef.

Return type:java.lang.String
linkHtml(Object ref[, Map<String, String> attrs])

Returns <a href=”….”> HTML link for transferred objects, which may have the following forms:

Example: Link to the page having GUID: 12d5c7a0c3167d3d21d30f1c43368b32 and class active

$!{linkHtml('12d5c7a0c3167d3d21d30f1c43368b32', ['class':'active'])}

As a result:

<a href="/siteroot/12d5c7a0c3167d3d21d30f1c43368b32"
   class='active'>
   Page name
</a>
Arguments:
  • String> attrs (Map<String,) – Optional parameter to set arbitrary attributes for the link tag <a>.
Return type:

java.lang.String

ogmeta([Map<String, String> params])

Open Graph - meta-information about the current page. For more details refer to: Support of Open Graph protocol.

A/B testing

abt(String name[, boolean def])

Returns true, if the A/B mode specified by the name argument is active

abtA()
abtB()
abtC()
abtD()

Returns true, if the A/B mode corresponding to method name is enabled.

Additional methods (Advanced)

asmNavChilds([String type][, Number skip][, Number limit])

Returns a collection of pages that are direct descendants of the current page within a navigation tree

Arguments:
  • type (String) – Page type
  • skip (Number) – Number of pages which will be skipped while fetching.
  • limit (Number) – The maximum number of pages in the selection.
Return type:

Collection<Asm>

asmPageQuery(PageCriteria critObj[, Number skip][, Number limit])

Select a pages matched a quiery specified by critObj which is an instance of com.softmotions.ncms.asm.PageCriteria

Arguments:
  • skip (Number) – Number of pages which will be skipped while fetching.
  • limit (Number) – The maximum number of pages in the result set.
Return type:

Collection<Asm>

com.softmotions.ncms.mhttl .HttlUtilsMethods

A number of utility methods for use in the context of HTTL templates.

Todo

TODO