close

Filter

loading table of contents...

Frontend Developer Manual / Version 2406.1

Table Of Contents

6.5.4 LiveContext (lc)

The LiveContext FreeMarker API provides utility functions of the LiveContextFreemarkerFacade to enrich pages with product specific data and components. It uses the namespace lc for template calls.

lc.formatPrice(amount, currency, locale)

Formats a given price according to the currency and locale.

Parameter Required Description
amount The numeric part of the price.
currency The currency of the price.
locale The locale to be used.

Table 6.54. Parameters of formatPrice


<#list self.orderItems![] as item>
  <#assign totalPriceFormatted=lc.formatPrice(item.price, item.product.currency, item.product.locale)/>
  <div>${totalPriceFormatted!""}</div>
</#list>

Example 6.42. List all items in a cart with given price


lc.createProductInSite(product)

To be used for a product representation in several sites.

Parameter Required Description
product A product representation.

Table 6.55. Parameter of createProductInSite


<#list self.orderItems![] as item>
  <#assign productInSite=lc.createProductInSite(item.product)/>
  <a href="${cm.getLink(productInSite)}">${item.product.name!""}</a>
</#list>

Example 6.43. List all product links in a cart


lc.previewMetaData()

Returns a map containing information for preview of fragments.

lc.augmentedContent()

Returns true if the current fragment request targets an Augmented Page.

lc.getVendorName()

Returns name of eCommerce Vendor like IBM, SAP Hybris, or coremedia

lc.getStatusUrl()

Returns the URL for the status handler to retrieve the actual state (logged in/logged out) of the user.

lc.getLoginFormUrl()

Returns the absolute URL to the login form of a commerce system.

lc.getLogoutUrl()

Returns the logout URL of a commerce system to logout the current user.

lc.availability(product, ifTrue, ifFalse, default)

Checks if the given product is available. If this is the case the String provided by parameter "ifTrue" will be rendered otherwise the String provided by parameter "ifFalse" will be used. If the availability check cannot be performed (for example, in a fragment preview) the value provided by parameter "default" is rendered.

Please take in mind that the value will be escaped before output. It is currently not possible to pass build-ins like ?no_esc.

Parameter Required Description
product The com.coremedia.livecontext.ecommerce.catalog.Product to check.
ifTrue The String to be rendered if the product is available. Defaults to true.
ifFalse The String to be rendered if the product is not available. Defaults to false.
default The String to be rendered if the availability cannot be checked (for example, in the fragment preview). Defaults to the value of parameter ifTrue.

Table 6.56. Parameters of available


<div class="cm-product <@lc.availability ifTrue="cm-product--available" ifFalse="cm-product--not-available" />>
  ...
</div>

Example 6.44. Render a CSS class depending on product availability


lc.createBeanFor(content)

Generates and returns a content bean for a content from the content type model. Used for pictures.

lc.createBeansFor(contents)

Generates and returns a list of content beans for a set of content from its corresponding content type model. Used for visuals and downloads of Products.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.