Using Content Link Functions

B2C Commerce provides a special syntax to define content link functions.

All content link functions use standard Salesforce B2C Commerce URL syntax, not the syntax used for URLs optimized for SEO. For information on this syntax, see URL Syntax.

Here are the content asset link functions:

Function Description
$staticlink$ Creates a static link.
$url()$ Creates an absolute URL that retains the protocol of the outer request.
$httpUrl()$ Creates an absolute URL, but with the http protocol.
$httpsUrl()$ Creates an absolute URL, but with the https protocol.
$include()$ Can be used to include the result of another server call.
$link$ Calls the Link pipeline in the Reference Application to call pipelines. In previous versions of B2C Commerce, this was the only way to link to pipelines. This is now deprecated.

$staticlink$

Creates a static content link.

Syntax ="...?$staticlink$"

When using $staticlink$ placeholders in content markup, the resulting generated links are absolute URLs and contain a host name. The results are regardless of the instance type, Production, or Sandbox. CDN-based URLs are also absolute URLs.

For example, the following content:

<p><a href="$url('Search-Show','cgid','mens')$">Mens</a>&lt;$&quot;/&gt;&nbsp;</p> 
<p><img width="400" height="400" alt="" src="images/large/10152_230.jpg?$staticlink$" />
&nbsp;</p>

Generates the following HTML:

<p><a href="http://localhost/on/demandware.store/Sites-SiteGenesis-Site/default/SearchShow?cgid=mens">Mens</a>
</p>
<p><img width="400" height="400" alt="" src="http://localhost/on/demandware.static/Sites-SiteGenesis-Site/Site/images/large/10152_230.jpg ""alt="">
</img>
</p>
Example:

This example shows how to include the function in your content asset, and the results of the link in the browser.

Asset Link

<img src="site/content/promo_small_1.gif?$staticlink$">

Result

Displays the image in the content asset.

$Url()$

Creates an absolute URL and retains the protocol of the outer request.

Syntax

$url(' <pipeline>' [, '<key1>', '<value1>', '<key2>', '<value2>', ...])$

Example:

This example shows the construction of the function, how to create a link in your content asset, and how the link appears in the browser. This example creates a link to the ABOUT_US content asset.

Function

$Url('Search-ShowContent', 'q', 'customer')$

Asset Link

<a title="My URL Search Link" target="_new" href="$Url('Search-ShowContent', 'q', 'customer')$"><span>URL Search Link Content Asset Link </span></a>

Result

http://[host]/default/Search-ShowContent?q=customer

$HttpUrl()$

Creates an absolute URL and retains the protocol "http".

Syntax

$httpUrl(' <pipeline>' [, '<key1>', '<value1>', '<key2>', '<value2>', ...])$

Example:

This example shows the construction of the function, how to create a link in your content asset, and how the link appears in the browser. This example creates a link to the Video category page.

Function

$httpUrl('Search-Show', 'cgid', 'J','psortb1','category-pos_J')$

Asset Link

<a title="My Http Link" target="_new" href="$httpUrl('Search-Show', 'cgid', 'J','psortb1','category-pos_J')$"><span>Http Link Content Asset Link </span></a>

Result

http://user-tw.inside.dw.customer.net/Video/J,default,sc.html?

psortb1=category-pos_J

$HttpsUrl()$

Creates an absolute URL and retains the protocol "https".

Syntax

$httpsUrl(' <pipeline>' (, '<key1>', '<value1>', '<key2>', '<value2>', ...))$

Examples:

This example creates a link to the Audio category page in the Reference Application. The link is to dynamic content that uses the Search pipeline.

Function

$httpsUrl('Search-Show', 'cgid', 'K')$

Asset Link

<a title="My Https Category Link" target="_new" href="$httpsUrl('Search-Show', 'cgid', 'K')$"><span>Https Category Link Content Asset Link </span></a>

Result


               https://
               <host>:<port>/on/demandware.store/Audio/K,default,sc.html
            

$Include()$

Creates a WAInclude with the given pipeline name and creates a relative URL. Can be used to include the result of another server call. A WAInclude is the result of a call to the B2C Commerce server. Usually, this call is a pipeline.

Syntax


               $include('<pipeline>' [, '<key1>', '<value1>', '<key2>', '<value2>', ...])$
            

Examples:

Function

$include('Search-Show', 'cgid', 'J','psortb1','category-pos_J')$

Asset Link

<a title="My Include Link" target="_new" href="$include('Search-Show', 'cgid', 'J','psortb1','category-pos_J')$"><span>Include Link Content Asset Link </span></a>

Result

<wainclude url="<URL without protocol, host and port>"/>

$Link$

Creates a link to the Link pipeline in the Reference Application. If you extend behavior, you can add other start nodes to the Link pipeline. This approach is an older version of static linking that can be present in code based on previous versions of B2C Commerce.

Caution

If a user makes a mistake in the definition, such as:


            $link-something
            &test=1$ 
         

The content object can never be opened again. The correct definition is:

$link-something:test...$.

Syntax

$link- <type>[:key1=value1;key2=value2; ...]$

Example:

This example links to the ABOUT_US content asset.

Function

$link-page:cid=ABOUT_US$ Asset Link

<a href="$link-page:cid=ABOUT_US$" title="Read more about us">

Result

http://[host]/About.Us/ABOUT_US,default,pg.html