Get content tag for retrieving externally managed content

Text content, such as HTML fragments for use in e-Marketing Spots, can be retrieved from an external content management system. When text content is retrieved from an external system to display on a store page, the content is retrieved while the store page is rendering. The wcst:getContent JSTL tag is used to accept and resolve content URLs to be valid for the store page where the content is to display. The tag is then used to retrieve the content from the resolved URL.

The wcst:getContent JSTL tag is used to embed the results of a specified URL to the location of content in an external content management system. The content that is retrieved must be text content that can be embedded within a store page. If the content to be retrieved contains URL references that are relative to the content location, the wcst:getContent tag updates the relative URL references to be fully qualified URLs. With the URL resolved, the URL is accessed and the text content that is found at the fully qualified URL is included on the store page. When the content is retrieved from the resolved URL location, the tag is used to write the content to a specified variable, or to the current JSPWriter if no variable is specified.

When this tag is included on a store page to resolve content URLs from an external system, the following attributes can be defined for wcst:getContent tag.
  • url - the URL of the content that is being retrieved. The unresolved URL can be specified with this attribute or in the body of the wcst:getContent tag.
  • var - the variable to which the content is assigned. If this variable attribute is not specified, the content is written to the current JSPWriter.
  • scope - the scope for the variable that is specified with the var attribute. The values for the scope attribute can be page, request, session, and application. The default value is page.

The content that this tag is used to get is retrieved by using the com.ibm.commerce.content.commands.GetContentCmd task command. This command invokes the URL specified for the tag and retrieves the content. The default implementation for the GetContentCmd task command is configured in the STORECONF database table. For more information about configuring the default implementation of this task command, see com.ibm.commerce.content.commands.GetContentCmdImpl.

Any unresolved content URLs must have the http://[cmsHost] prefix. These unresolved URLs are then resolved with the com.ibm.commerce.content.commands.ResolveContentURLCmd task command. When this command is called, the URL is called from the WebSphere Application Server. The default implementation of the task command replaces http://[cmshost] prefix with the host name for the wc.resolveContentURL.cmsInternalHost key that is in the STORECONF database table. If the command does not detect the http://[cmsHost] prefix, then the URL is considered to be resolved. For more information about configuring the default implementation of this task command, see com.ibm.commerce.content.commands.ResolveContentURLCmdImpl.

Caching the get content tag

The command for the wcst:getContent tag can be cached. To enable the caching of this command, add the following cachespec entry into the cachespec.xml
<cache-entry>
  <class>command</class>
  <sharing-policy>not-shared</sharing-policy>
  <name>com.ibm.commerce.content.commands.GetContentCmdImpl</name>
  <cache-id>
    <component type="method" id="getCacheId">
      <required>true</required>
    </component>
    <priority>1</priority>
    <timeout>3600</timeout>
    <inactivity>600</inactivity>
  </cache-id>
  <dependency-id>getContent</dependency-id>
</cache-entry>
With the caching enabled, store pages can embed the content from an external content management system. The embedded content might need to be invalidated if the source content changes. To invalidate this cached content, timeouts can be set for cache invalidation, or the cache can be flushed when necessary. If explicit cache invalidation is necessary, complete the following procedure.
  1. Determine the content URLs that are changed. Comparing previously pre-rendered files with the newly pre-rendered files can help identify the changed URLs. Ignore the content that does not have a MIME type that is text. Content other than text is not cached by and is loaded by the browser directly. The text content can be cached and consumed by e-Marketing Spots on a store page when the e-Marketing Spot is rendered.
  2. Determine the rows in the database table that references any of the URLs that are changed. The content URLs are recorded in the ATCHASTPATH column for the table.
  3. Use the stagingprop utility to insert records into the production database to invalidate the e-Marketing Spots that reference the changed content. Alternatively, update the TIMEUPDATED column of the ATCHAST table by running the following SQL
    update atchast set timeupdated = current timestamp where atchastpath in ('http://[cmsHost]/contentPath');
    Where http://[cmsHost]/contentPath is the content URL to the changed content.
    Note: If you must manually insert the CACHEIVL records into the production database, use the following SQL
    insert into cacheivl (dataid) values ('contentId:collateral_Id'); 
    
    
    Where collateral_Id is the value in the COLLATERAL_ID column of the database table. To identify all of the rows in the COLLATERAL table that are related to the content that is changed, you must reference the table. This table records the relationship between entries in the COLLATERAL and ATCHAST tables. To retrieve a list of COLLATERAL_ID values that reference a changed piece of content, such as http://[cmsHost]/contentPath, use the following SQL
    select object_id from atchrel 
    where atchobjtyp_id = 4 
    and atchtgt_id in (select atchtgt_id from atchast where atchastpath in ('http://[cmsHost]/contentPath'));