Content Assets

You can extend a content asset with its own attributes using the metadata system.

In Salesforce B2C Commerce, a content asset is a database object with attributes. The most common usage for content assets is to contain HTML that appears on the storefront as a standalone page or embedded within another page. Content assets are typically used for information that changes infrequently such as an about us page or apparel sizing tables. These HTML blocks can reference images that are stored in a special area of the file system for content-related static files.

You can customize how content assets behave in B2C Commerce. The following describes customization options.

  
Import and export and export

You can import the content assets you use in your application, and you can export the content of one site into another site. You can also export the content assets of a private library into a shared library.

Attributes and system objects

You can use attributes and system objects to define storefront content.

The Content system object, for example, supports site-specific attributes. Several existing attributes, including the onlineFlag attribute, are site-specific. You can use this feature to specify content differences between sites that share the same content assets. For example, if the contents for two brands reside in the same shared library, you can specify the onlingFlag attribute so that the brand-specific content only appears on the site for that brand.

Other site-specific attributes are: searchableFlag, siteMapChangeFrequency, siteMapPriority, and siteMapIncluded.

Content links

When you create content assets, you can add links to other content assets, search results, or product detail pages. B2C Commerce provides a special syntax to define these links. You can also use content links to link to external web sites or other B2C Commerce sites.

Content slots

Use content slots to show targeted content on predefined browser areas.

Content APIsYou can use the B2C Commerce APIs to customize how your storefront application handles content assets.
Before you begin, consider the best practices related to potential security ramifications.

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:

FunctionDescription
$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

Create Content Asset Links 

You can create links to other sites or content assets.

  1. Decide if you want to link to:

    • Another site
    • Static content in your site - can be an image, product page, or article
    • Dynamic content in your site - is content that is determined when the link is clicked. For example, to link to a set of search results, you create a link to a pipeline that performs the search and returns the search results. Developers for your site can tell you the name and parameters of pipelines you can use.
  2. Determine the type of link to create.

  3. Open your browser and look at the URL of the page or image you want to link to.

    • If your URL looks like a URL outside your domain (www.otherstore.com), link to another site's domain.
    • If your URL looks like a category page or search result, use the Product or Category page URL hyperlink feature.
    • If your URL looks like an image, product or content asset, link to a static content asset.
  4. When creating or editing a hyperlink within a content asset, select one of these link types:

    • URL

    • Product detail page URL

    • Category page URL

    • Content page URL

    • Link to anchor in the text

    • E-Mail When you edit a hyperlink in the HTML editor using the Link editor, the link value you enter is not used. The link text only changes when changing the:

    • Product SKU of a product detail page URL: if the product exists for the SKU or is set to the value the user entered, the link text is changed to the display name of the product.

    • Category ID of a catalog category page URL: if a catalog category exists for the ID or is set to the value the user entered, the link text is changed to the display name of the catalog category.

    • Content Asset ID of a content page URL: if a content asset exists for the given ID or is set to the value the user entered, the link text is changed to the display name of the content asset.

    • Search Phrase of a keyword search URL: the link text is changed to the new search phrase.

    • Protocol or the URL of a normal URL and the link text was equal to the previous protocol plus the URL: the link text is changed to new protocol plus the new URL.

  5. For Product, Category, and Content page URLs, enter a product SKU, category ID (of a category in the storefront catalog) or content asset ID (of an asset in the site library) respectively. The system generates the appropriate URL. If you create a hyperlink, the link text defaults to the display name of the product, category, or content asset in the currently selected locale. This is from the HTML view.

Content asset links for images are usually to folders in your image library. You can't use the content asset editor to dynamically create an absolute URL for an image in a content asset link that includes the full path to the image. Instead, you must either post-process the markup of your assets by using placeholders such as #hostname#. The placeholders are replaced with the correct value programmatically before outputting the markup or hard code the full image URLs from production into your asset. This is only a consideration if you are including content assets in emails.

Linking to Another Site URL 

You can include another site URL in your content asset, as you would for any HTML page.

This example links to the Salesforce B2C Commerce homepage.

<a title="Visit the B2C Commerce Homepage" href="http://www.demandware.com/">www.demandware.com</a>

Linking to a Pipeline 

You can link to any pipeline using the $url()$, $httpUrl()$, $httpsUrl()$, or $include()$ content link functions. You can also link to the SiteGenesis Link pipeline using the $link$ function.

Each pipeline requires different information to be passed to it. You specify this information in the link.

In this example, you are linking to the link pipeline product subpipeline and sending it a product id.

<a href="$link-product:pid=S1917353$">Microsoft Xbox - Game console</a>

To change this link to a different product, change the value for the pid argument:

<a href="$link-product:pid=S2364458$ ">Nikon UR E17 - Lens adapter</a>

Linking to Static Content 

Static content includes products, content assets, images, and email links.

The $staticlink$ functionality is the best way to create a URL to a static file in a library or catalog. This approach passes the correct unit, product, catalog, or library. The result is the creation of the correct static content URL. If you prefer, you can use the other content link functions.

Product Link Example

<a href="$link-product:pid=S1917353$">Microsoft Xbox - Game console</a>

Content Asset Link Example

<a href="$link-page:cid=ABOUT_US$" title="Read more about us"> <span>About Us</span></a><span class="divider">|</span></a>

Image Link Example

<img height="356" width="705" src="demo/content/homepage_705_356_flatpanel.gif?$staticlink$" alt="Flat Panel Promotion" />

Email Link Example

<a href="mailto:info@salesforce.com" title="Contact Us via EMail">info@salesforce.com</a>

Content Asset Link Examples 

These scenarios include several examples of creating or updating links in content assets.

Updating an Existing Link 

You can easily update an existing link by changing the values that determine the category, content asset, image, or page.

To change a category Link

Find “cgid” (category ID) and change the next value to the category ID you want to link to. If the name of the category is included in the link, find the name and change it.

Change...

<a title="Category Search Link" target="_new" href="$httpUrl('Search-Show', 'cgid', 'P')$">
<span>Pans Search Link</span></a>

To

<a title="Category Search Link" target="_new" href="$httpUrl('Search-Show', 'cgid', 'J')$">
<span>Jams Search Link</span></a>

To change a product Link

Find “pid” (product ID) and change the next value. There can be more than one type of link, but they all use pid in the link to indicate a product.

Change...

<a title="MapSource BlueChart" target="_new" href="$httpUrl('Product-Show', 'pid', 'S1965524')$">
<span>MapSource BlueChart</span></a>

To

<a title="Terrain Navigator" target="_new" href="$httpUrl('Product-Show', 'pid', 'S2150489')$">
<span>Terrain Navigator</span></a>

To change a content asset Link

Find “cid” (content asset ID) and change the next value. All links use cid in the link to indicate a content asset.

Change...

<a href="$httpUrl('Page-Show', 'cid', 'about-us')$"> About Us</a>

To

<a href="$httpUrl('Page-Show', 'cid', 'gift-details')$"> Gift Details</a>

To change an image Link

Find “src” and change the image path.

Change...

<img
  width="750"
  height="715"
  alt=""
  usemap="#instyle"
  src="images/asSeenIn/InStyle.jpg?$staticlink$"
/>

To

<img
  width="750"
  height="715"
  alt=""
  usemap="#people"
  src="images/asSeenIn/People.jpg?$staticlink$"
/>

To change an email Link

Find “mailto:” and change the email address.

Change...

<a href="mailto:rgeiger@salesforce.com">rgeiger@salesforce.com</a>

To

<a href="mailto:freinhardt@salesforce.com">freinhardt@salesforce.com</a>

Content Data Administration 

When replicating content asset libraries, shared and private libraries appear differently in the Replication Tasks page.

For example:

Section on Replication Tasks page...Looks like...
Global section
  • Libraries
  • Library1
  • Library2
Site1 section
  • Site
  • Content Library

The assignment of libraries to sites is done through the site-level Site Preferences replication task. The Site Preferences replication task makes it possible to:

  • create a shared library on Staging.
  • assign it to a site A on Staging.
  • replicate the library itself without the site being changed to actually use the library on the production instance.

WebDAV

You can access content asset static files within a library using WebDAV. See the instructions by selecting Administration > Site Development > Development Setup.

The URL is specified as follows:

https://host/on/demandware.servlet/webdav/Sites/Libraries/{Site name}

The value after /Libraries/ is interpreted as either a site ID or a shared library ID. If it's a site ID, the URL references the private library of the specified site. If not, then Salesforce B2C Commerce attempts to find a shared library with that ID. If the value is neither, the operation fails.

Content Asset APIs 

You can use these Salesforce B2C Commerce APIs to customize your storefront application relative to libraries and content assets for both private and shared libraries.

B2C Commerce Script APIs 

These APIs support both private and shared libraries.

ClassMethod
dw.content.ContentMgr

  • getSiteLibrary();
  • getContent(String id);

dw.content.Content

  • getOnlineFlag();
  • isOnline();
  • getSiteMapChangeFrequency();
  • getSiteMapPriority();
  • getSiteMapIncluded();
  • getSearchableFlag();

dw.web.URLUtils

URL staticURL(String context, String contextID, String relPath); - enables you to specify the ID of any shared library in B2C Commerce. It isn't possible to generate a URL that points to the private library of another site.

dw.io.File

File access to all libraries, folders, and content, for example:

LIBRARIES/{Library Name}(/...)

B2C Commerce uses a fall-back mechanism to determine the site library path. It first checks to see if the token represents the ID of a site in B2C Commerce. If it does, it constructs a file path within the private library of that site. If the token isn't the ID of a site, then B2C Commerce interprets it as the ID of a shared library within B2C Commerce. You can use this mechanism to construct file paths for private and shared libraries (as long as there are no naming conflicts).

Pipelets 

These pipelets support both private and shared libraries: GetContent, ImportContent, and ExportContent